CEO @ ESCEMI and CTO @ Your service
- 📫 How to reach me https://www.linkedin.com/in/emilienescalle/
Zend Framework module for easy integration of Twitter Bootstrap
Home Page: http://neilime.github.io/zf2-twb-bundle/
License: MIT License
Hi,
I have setup a local ZendSkeletonApplication with directory vendor, here I have the following structure : directory bootstrap (containing directories docs, img, js, less and a couple of files) and directory zf2-twb-bundle (containing directories config, src, tests, vendor and a couple of files). I cannot use git locally so I downloaded the zips, unpacked them and renamed them and put them in de vendor directory:
ZendSkeleton
Hi,
I have also updated your FormCollectionTwb.php in order to include dynamic add/remove capabilties.
public function render(ElementInterface $element)
{
$renderer = $this->getView();
if (!method_exists($renderer, 'plugin')) {
// Bail early if renderer is not pluggable
return '';
}
$markup = '';
$templateMarkup = '';
$escapeHtmlHelper = $this->getEscapeHtmlHelper();
$elementHelper = $this->getElementHelper();
$fieldsetHelper = $this->getFieldsetHelper();
if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
$templateMarkup = $this->renderTemplate($element);
}
foreach ($element->getIterator() as $elementOrFieldset) {
if ($elementOrFieldset instanceof FieldsetInterface) {
$markup .= $fieldsetHelper($elementOrFieldset);
} elseif ($elementOrFieldset instanceof ElementInterface) {
$markup .= $elementHelper($elementOrFieldset);
}
}
// If $templateMarkup is not empty, use it for simplify adding new element in JavaScript
if (!empty($templateMarkup)) {
$markup .= $templateMarkup;
}
// Every collection is wrapped by a fieldset if needed
if ($this->shouldWrap) {
$label = $element->getLabel();
if (!empty($label)) {
if (null !== ($translator = $this->getTranslator())) {
$label = $translator->translate(
$label, $this->getTranslatorTextDomain()
);
}
$label = $escapeHtmlHelper($label);
$markup = sprintf(
'<fieldset><legend>%s</legend>%s</fieldset>',
$label,
$markup
);
}
}
return $markup;
}
With the fieldset's attributes, I join my own js widget code ;
( add button + remove button + hide useless legend)
; if ( typeof Object.create !== 'function' ) {
Object.create = function( obj ) {
function F() {};
F.prototype = obj;
return new F();
};
}
(function( $, window, document, undefined ) {
/*
* Object Class
*
*/
var ElementCollection = {
init: function( options, elem ) {
var self = this;
self.elem = elem;
self.$elem = $( elem );
self.options = $.extend( {}, $.fn.elementCollection.defaults, options );
self.count = self.$elem.data('count') ? self.$elem.data('count') : 0 ;
self.add = self.$elem.data('add') ? self.$elem.data('add') : false;
self.remove = self.$elem.data('remove') ? self.$elem.data('remove') : false;
self.positions = [];
self.currentCount = self.getCurrentCount();
for (var i=0;i<self.currentCount;i++)
{
self.positions.push(i) ;
}
self.legend = (self.$elem.find("> legend").text() ) ? self.$elem.find("> legend").text() : "";
self.refresh();
},
hideLegend:function(){
var self = this;
self.$elem.find("> fieldset > legend").hide();
},
isAddValid:function(){
var self = this;
self.getCurrentCount();
if (self.add)
return true;
else
return false;
},
isRemoveValid:function()
{
var self = this;
self.getCurrentCount();
if (self.remove && (self.currentCount > self.count) )
return true;
else
return false;
},
getCurrentCount:function()
{
var self = this ;
self.currentCount = self.$elem.find('> fieldset').length;
return self.currentCount ;
},
manageAddBtn:function()
{
var self = this;
if(self.isAddValid())
{
if(self.$elem.find("> a#add").length==0)
{
//var newItem = $(self.legend+' <a id="add" href="#" class="btn" style="display:inline-block"><i class="icon-plus"></i>Add</a>').hide();
var newText = self.legend +' <a id="add" title="Add" href="#" class="btn btn-small btn-success" style="display:inline-block; margin-left:20px"><i class="icon-plus"></i></a>';
//self.$elem.find("> legend").after(newItem);
self.$elem.find("> legend").html(newText);
//newItem.fadeToggle(250);
}
}
else
self.$elem.find("> a#add").fadeToggle(250).detach();
},
manageRemoveBtn:function()
{
var self = this;
if(self.isRemoveValid())
{
self.$elem.find("> fieldset").each(
function(){
if($(this).find("> a#remove").length==0)
{
var newItem = $('<a id="remove" title="Remove" href="#" class="btn pull-right btn-small btn-danger"><i class=" icon-remove"></i></a>').hide();
$(this).prepend(newItem);
newItem.fadeToggle(250);
}
});
}
else{
self.$elem.find("> fieldset > a#remove").fadeToggle(250).detach();
}
},
addObject:function(){
var self = this;
if(self.isAddValid())
{
var template = self.$elem.find('> span').data('template');
for (var i=0;i<self.currentCount;i++)
{
if (self.positions.indexOf(i) == -1)
{
break ;
}
}
template = template.replace(/__index__/g, i);
self.positions.push(i);
var newItem = $(template).hide();
newItem.find('select').select2({
placeholder: "Select...",
allowClear: true,
width:"element",
});
self.$elem.append(newItem);
newItem.fadeToggle(500);
}
self.refresh();
},
removeObject:function($element){
var self = this;
if(self.isRemoveValid())
{
//self.positions index()
var index = self.$elem.find('>fieldset').index($element);
self.positions= jQuery.grep(self.positions, function(value) {
return value != index;
});
$element.fadeToggle(500).detach();
}
self.refresh();
},
refresh:function(){
var self = this;
self.manageAddBtn();
self.manageRemoveBtn();
self.$elem.find("> legend > a#add").click(function(e){
e.preventDefault();
self.addObject();
});
self.$elem.find("fieldset > a#remove").click(function(e){
e.preventDefault();
self.removeObject($(this).parent());
});
self.hideLegend();
}
};
/*
* Constructor
*
*/
$.fn.elementCollection = function( options ) {
return this.each(function() {
var elementCollection = $.data( this, 'elementCollection');
if (!elementCollection){
elementCollection = Object.create( ElementCollection );
if ( typeof options === 'object' || ! options ){
elementCollection.init( options, this );
return ;
}
else
elementCollection['init'].apply( this, Array.prototype.slice.call( arguments, 1 ));
$.data( this, 'elementCollection', elementCollection );
}else
{
if ( elementCollection[options] ) {
elementCollection[options].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof options === 'object' || ! options ) {
elementCollection.init( options, this );
} else {
$.error( 'Method ' + options + ' does not exist on jQuery.elementCollection' );
}
}
});
};
$.fn.elementCollection.defaults = {
};
})( jQuery, window, document );
Hope that could help you to improve your module :-)
S
title says it all really ;)
This module will support to button groups?
Hey Neilime, you made a good module.
I'm gonna contribute this week, I got one or two bug fixes for you, but in the installation you mention a 2.0 version. But "neilime/zf2-twb-bundle": "2.0" really doesnt work for me. Don't you mean "neilime/zf2-twb-bundle": "1.0-dev"?
Maybe more people have problems with 2.0 not working.
Je ne parviens pas à utiliser votre module sur une installation nouvelle d'un ZEND Framework. Auriez vous un exemple complet d'utilisation svp ?
Great plugin, and the examples of the form work lovely. But if the example form is made to be a fieldset of a field object, then it is not rendered as the original form is.
Is it possible to make fieldsets rendered the same? Alternatively could you write a tutorial on rendering fieldsets / multiple fieldsets in a form in?
What do you think to add some options to add other elements on the side (prepend or append like addon)
For example:
Label:
If we add something like elements-append and elements-prepend, what do you think?
There is no tag 2.0 so this
"require": {
"neilime/zf2-twb-bundle": "2.0"
}
doesn't work!
Hi,
Today I updated an application by composer e when deploy my project appeared the error:
Declaration of TwbBundle\Form\View\Helper\TwbBundleFormElement::setTranslator() must be compatible with that of Zend\I18n\Translator\TranslatorAwareInterface::setTranslator() in C:\wamp\www\superfritas\vendor\neilime\zf2-twb-bundle\src\TwbBundle\Form\View\Helper\TwbBundleFormElement.php on line 5
Please, change the parameter type in line 150 to \Zend\I18n\Translator\Translator
PHP Fatal error: Declaration of TwbBundle\\Form\\View\\Helper\\TwbBundleFormElement::setTranslator() must be compatible with Zend\\I18n\\Translator\\TranslatorAwareInterface::setTranslator(Zend\\I18n\\Translator\\TranslatorInterface $translator = NULL, $textDomain = NULL) in /path/vendor/neilime/zf2-twb-bundle/src/TwbBundle/Form/View/Helper/TwbBundleFormElement.php on line 4,
Where "path" is the path, not put to have no problems ...
What is the absolute path of my server
I am getting the following error when displaying the zfcuser registration form. I have tried looking at: TwbBundleFormElement.php but I'm not sure why it's causing this error.. The declaration seems to be the same.
Fatal error: Declaration of TwbBundle\Form\View\Helper\TwbBundleFormElement::setTranslator() must be compatible with Zend\I18n\Translator\TranslatorAwareInterface::setTranslator(Zend\I18n\Translator\Translator $translator = NULL, $textDomain = NULL) in C:\xampp\htdocs\budquest\vendor\neilime\zf2-twb-bundle\src\TwbBundle\Form\View\Helper\TwbBundleFormElement.php on line 5
While using:
array(
'name' => 'display',
'type' => 'Zend\Form\Element\Radio',
'options' => array(
'label' => 'Display category',
'value_options' => array(
'1' => 'Yes',
'0' => 'No',
)
)
)
Lables don't get rendered.
Fix on 'TwbBundle\Form\View\Helper\TwbBundleFormRow.php' line 99:
//Render element input
//if($sLayout !== \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL)return $this->getElementHelper()->render($oElement);
//$sLabelOpen = $sLabelClose = $sLabelContent = '';
$oLabelHelper = $this->getLabelHelper();
$aLabelAttributes = $oElement->getLabelAttributes()?:$this->labelAttributes;
if($aLabelAttributes)$oElement->setLabelAttributes($aLabelAttributes);
$sLabelOpen = $oLabelHelper->openTag($oElement);
$sLabelClose = $oLabelHelper->closeTag();
$sLabelContent = $this->getEscapeHtmlHelper()->__invoke($sLabelContent);
Note: This is just a quick/dirty fix.
EDIT: see #24 for a better fix
Composer configuration haven't worked for me, I had to change it from
"neilime/zf2-twb-bundle": "2.0"
to
"neilime/zf2-twb-bundle": "dev-master"
For example
echo $this->formDateTime($form->get('element-date-time'));
echo $this->formDateTimeLocal($form->get('element-date-time-local'));
echo $this->formTime($form->get('element-time'));
echo $this->formDate($form->get('element-date'));
echo $this->formWeek($form->get('element-week'));
echo $this->formMonth($form->get('element-month'));
echo $this->formEmail($form->get('element-email'));
echo $this->formUrl($form->get('element-url'));
echo $this->formNumber($form->get('element-number'));
echo $this->formRange($form->get('element-range'));
echo $this->formColor($form->get('element-color'));
If i'm use it like in example, elements generates without Bootstrap.
But this works with Bootstrap
echo $this->formCollection($form);
Hi Neilime,
When will version 2.0 be available so that I can update my project using composer?
Regards
Steve
When using fieldsets without twb-bundle, they get rendered correctly:
<input type="text" name="fieldset_name[field_name]" />
When twb-bundle is active, they do not get rendered correctly:
<input type="text" name="field_name" />
This breaks forms using fieldsets.
I am using <?php echo $this->form()->render($this->form);
for rendering.
ZF Version 2.x does not ship with a standard FormErrors view helper, like in ZF1:
http://framework.zend.com/manual/1.12/en/zend.form.standardDecorators.html#zend.form.standardDecorators.formErrors
This was by design - it was not forgotten. However, I believe we should include one in this library to be used with the $this->form() view helper.
I have implemented one on my fork here:
https://github.com/henryhayes/zf2-twb-bundle/blob/master/src/TwbBundle/Form/View/Helper/TwbBundleFormErrors.php
Use Example:
In the view:
Please could you review this and let em know if I have missed anything, or any design improvement suggestions would be appreciated. After this, I will ensure it has suitable unit tests and an entry is added to the module.config.
hello
i want to make a checkbox label position append instead of prepend
because it render the input element inside the label tag ... i dont want this !
plz help
hi
i have a form with a fieldset ...
my fieldset has 4 input element
i want to make the fieldset render inline (without view helper) because i render my whole form ... not fieldset by fieldsets ....
this pull request not works -> #41
plz help
diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php
index 0aa4bd7..27ebe39 100644
--- a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php
+++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php
@@ -148,6 +148,8 @@ class TwbBundleFormRow extends \Zend\Form\View\Helper\FormRow{
}
elseif(empty($aLabelAttributes['class']))$aLabelAttributes['class'] = 'control-label';
elseif(strpos($aLabelAttributes['class'], 'control-label') === false)$aLabelAttributes['class'] .= ' control-label';
+
if ($oElement->getAttribute('required') === true) $aLabelAttributes['class'] .= ' required';
$oLabelHelper = $this->getLabelHelper();
hello friend okay? excuse my ignorance but I tried everything and it was like I could not integrate with fontello ... or perhaps not possible, so ask. also tried to integrate Font Awesome, but it works only when all features silent environment to Production ...
http://fortawesome.github.io/Font-Awesome/
http://fontello.com/
Please, I just loved your project and would like to use it but it is an issue that would impact .. as develop sources ... just need a feature that accept source as icons.
Hug and congratulations on your initiative.
My composer.json
{
"name" : "zendframework/skeleton-application",
"description" : "Skeleton Application for ZF2",
"keywords" : [
"framework",
"zf2"
],
"homepage" : "http://framework.zend.com/",
"license" : [
"BSD-3-Clause"
],
"require": {
"php": ">=5.3.3",
"zendframework/zendframework" : "2.2.*"
},
"minimum-stability" : "dev",
"require" : {
"doctrine/doctrine-module" : "0.7.1",
"doctrine/doctrine-orm-module" : "0.7.0",
"doctrine/data-fixtures" : "v1.0.0-ALPHA3",
"doctrine/migrations" : "dev-master",
"neilime/zf2-twb-bundle" : "dev-master",
"neilime/zf2-assets-bundle" : "dev-master",
"neilime/zf2-tree-layout-stack" : "dev-master",
"twitter/bootstrap" : "dev-master",
"zendframework/zend-developer-tools" : "dev-master",
"zendframework/zendoauth" : "dev-master",
"zendframework/zendservice-api" : "dev-master",
"zendframework/zendpdf" : "dev-master",
"zendframework/zendservice-recaptcha" : "dev-master"
},
"repositories" : [
{ "type" : "vcs", "url" : "http://github.com/Nodge/lessphp" }
]
}
I have a collection with fieldset and hidden input inside. and when generating html it gennerates:
<div class="form-group ">
<input class="form-control" type="hidden" value="" name="answers[0][id]">
</div>
I don't think this div should be here because form-group
adds additional padding and so on.. Or maybe there is a way to fix this if this isn't done automaticly?
Hello,
I use ZF2.2.6.
When create form like this :
class DevisForm extends Form {
protected $captcha;
public function __construct($name = null) {
parent::__construct($name);
$this->setName('devis');
$this->setAttribute('method', 'post');
$this->setAttribute('novalidate', 'novalidate');
$this->setAttribute('class', 'form-horizontal');
/*
* ETAT CIVIL
*/
$this->add(array(
'name' => 'civilite_adherent',
'type' => 'Zend\Form\Element\Select',
'attributes' => array(
'value' => 'M.'
),
'options' => array(
'label' => 'Civilité',
'value_options' => array(
'M.' => 'M.',
'Mle' => 'Mle',
'Mme' => 'Mme',
),
),
));
...
and in the view call :
$this->form($oForm);
It blank nothing to appear.... and no errors.... Why ???
I try use following code to display icon in my button:
$this->add(new \Zend\Form\Element\Button('test-button', array(
'label' => 'test-button',
'twb' => array(
'icon' => 'icon-info'
)
)));
and
$this->formButton($this->form->get('test-button'))
but display button without icon.
Thanks.
Hi,
It's more like a help and about your opnion...
Before I use TwbBundle when I added new element I created new class inherit from FormElement, but now you overwrite this class, what do you think it's the best way to create new element?
If I overwrite your class I will need to duplicate a lot of code when I only need change this line:
https://github.com/neilime/zf2-twb-bundle/blob/master/src/TwbBundle/Form/View/Helper/TwbBundleFormElement.php#L51
What do you think?
( ! ) Catchable fatal error: Argument 1 passed to Zend\Form\View\Helper\AbstractHelper::createAttributesString() must be of the type array, null given, called in /vendor/neilime/zf2-twb-bundle/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php on line 50 and defined in /vendor/zendframework/zendframework/library/Zend/Form/View/Helper/AbstractHelper.php on line 204
This solved the issue for me. Change /vendor/neilime/zf2-twb-bundle/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php
if($this->shouldWrap && ($sLabel = $oElement->getLabel())){
if(null !== ($oTranslator = $this->getTranslator()))$sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain());
$labelAttributes = ($oElement->getLabelAttributes()) ? $oElement->getLabelAttributes() : array() ;
$sMarkup = sprintf(
self::$legendFormat,
$this->createAttributesString($labelAttributes),
$this->getEscapeHtmlHelper()->__invoke($sLabel)
).$sMarkup;
}
Hi,
I have updated my composer.json to last stable version (2.2.0) but now I'm receiving this error, when I run composer.phar install command.
The request package requested neilime/zf2-twb-bundle could not be found in any version, there may be a typo in the package name.
However, in Packagist there is this version:
https://packagist.org/packages/neilime/zf2-twb-bundle
in my composer.json I have:
"neilime/zf2-twb-bundle": "2.2.0"
I'm doing something wrong?
Thanks
Hello and good day,
First, Thanks for the good work on this module.
I have his issue trying to use the formCollection
line 33 has a call to the function getFieldsetHelper() which can't be found
Thanks
When rendering input which has no id, label gets "for" attribute referencing name of input which is incorrect. http://www.w3.org/wiki/HTML/Elements/label states:
for = string - The attribute's value must be the ID of a labelable form-associated element...
TwbBundleFormRow::renderElement() calls (Zend)LabelHelper->openTag($oElement) but openTag() won't check existence of ID attribute and will substitute NAME.
Zend FormRow helper will without ID call openTag() with only array of labelAttributes, so it can't find the name and will not generate invalid FOR.
On the other side - it will always generate input inside label. I don't know if it's even possible to render TWB form inputs inside labels or maybe autogenerate IDs.
For generating a checkbox my current view would look like this:
<tr>
<td class='right-label'><?php echo $this->formLabel($contract->get('show_in_oem')); ?></td>
<td><?php echo $this->formcheckbox($contract->get('show_in_oem')); ?></td>
</tr>
Which then would generate:
<tr>
<td class="right-label"><label for="contract[show_in_oem]">Show in OEM</label></td>
<td><input type="hidden" value="0" name="contract[show_in_oem]"><input type="checkbox" value="1" class="form-control" name="contract[show_in_oem]"></td>
</tr>
As you can see I have to separate the label from the checkbox.
Now, after switching to twb the same code generates this HTML:
<tr>
<td class="right-label">
<label for="contract[show_in_oem]">Show in OEM</label>
</td>
<td>
<div class="checkbox">
<input type="hidden" value="0" name="contract[show_in_oem]">
<label>
<input class="form-control" type="checkbox" value="1" name="contract[show_in_oem]">
Show in OEM
</label>
</div>
</td>
</tr>
When disabling TWB via elements' options this is the result:
<tr>
<td class="right-label">
<label for="contract[show_in_oem]">Show in OEM</label>
</td>
<td>
<input type="hidden" value="0" name="contract[show_in_oem]">
<label>
<input class="form-control" type="checkbox" value="1" name="contract[show_in_oem]">
Show in OEM
</label>
</td>
</tr>
Though I know that appending the label to the checkbox may be the expected Twitter Bootstrap 3 behaviour for horizontal forms maybe there are use cases where the label needs to be separated.
Is there an option to achieve this?
Since a recent commit labels are missing the 'for' / 'id' attribute.
In class TwbBundleForm, is default the css class "form-horizontal" to form layout, but in documentation bootstrap has a first example of how use form without layout http://getbootstrap.com/css/#forms. I think wich "form-horizontal" can be the class default, but the function openTag doesn't have option to change form layout.
This example:
openTag(\Zend\Form\FormInterface $form = null,$sFormLayout = self::LAYOUT_HORIZONTAL)
or
openTag(\Zend\Form\FormInterface $form = null,$sFormLayout = '')
Hi!
I followed docs and installed module into ZF2, form in documentation couldn't be rendered.
I catch this exception:
PHP message: PHP Fatal error: Declaration of TwbBundle\Form\View\Helper\TwbBundleFormElement::setTranslator() must be compatible with that of Zend\I18n\Translator\TranslatorAwareInterface::setTranslator() in /home/jumper/Projects/malinink/vendor/neilime/zf2-twb-bundle/src/TwbBundle/Form/View/Helper/TwbBundleFormElement.php on line 3
Changing this function declaration to setTranslator(\Zend\I18n\Translator\TranslatorInterface ... )
fixes issue.
But I still didn't catch why this bug happens?
I have a CompanyFieldset php, which - beside other elements - adds this one:
$phoneFieldset = new PhoneFieldset($objectManager);
$this->add(array(
'type' => 'Zend\Form\Element\Collection',
'name' => 'phones',
'options' => array(
'count' => 2,
'target_element' => $phoneFieldset
)
));
The CompanyFieldset is added like this in the CompanyForm:
$companyFieldset = new CompanyFieldset($objectManager);
$companyFieldset->setUseAsBaseFieldset(true);
$companyFieldset->setName('company');
$this->add($companyFieldset);
The elements - other than the PhoneFieldset - are shown, but not the PhoneFieldset.
Is there an issue with OneToMany connections? (OneToOne works fine.)
Thank you!
Hello,
I got this error when I tried to integrate the zf2-twb-bundle into the Zend Skeleton Application (v2.3.0).
Fatal error: Declaration of
TwbBundle\Form\View\Helper\TwbBundleFormElement::setTranslator()
must be compatible with
Zend\I18n\Translator\TranslatorAwareInterface::setTranslator(Zend\I18n\Translator\TranslatorInterface $translator = NULL, $textDomain = NULL)
in "zf2-twb-bundle\src\TwbBundle\Form\View\Helper\TwbBundleFormElement.php"
I Solved the problem by replacing this:
public function setTranslator(\Zend\I18n\Translator\Translator $oTranslator = null,
$sTextDomain = null)
with this:
public function setTranslator(\Zend\I18n\Translator\TranslatorInterface $oTranslator = null,
$sTextDomain = null)
Problem 1
- Installation request for neilime/zf2-twb-bundle dev-master -> satisfiable by neilime/zf2-twb-bundle dev-master.
- neilime/zf2-twb-bundle dev-master requires twitter/bootstrap dev-master -> no matching package found.
Edit:
Found this: http://getcomposer.org/doc/faqs/why-can%27t-composer-load-repositories-recursively.md
Maybe remove bootstrap as required module?
There is misspell for parameter "colunm-size" in classes: TwbBundleFormRow and TwbBundleForm. Correct value is "column-size"
Hi,
Thanks for sharing your code :-)
I have "hacked" TwbBundleForm.php in order to not wrap a fieldset when useAsBaseFieldset is active.
Line 38 :
if($oElement instanceof \Zend\Form\FieldsetInterface)
{
$shouldWrap = (method_exists($oElement, 'useAsBaseFieldset')) ? !$oElement->useAsBaseFieldset() : true;
$sFormContent .= this->getView()->formCollection($oElement,$shouldWrap,$sFormLayout);
}
Hope that you will consider this in your next commit
See u
Notice: Undefined property: TwbBundle\Form\View\Helper\TwbBundleFormRow::$partial in /home/www/reg.net/vendor/neilime/zf2-twb-bundle/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php on line 45
form:
class ItemForm extends Form
{
public function __construct($name = null)
{
parent::__construct('item');
$this->setAttribute('method', 'post');
$this->setAttribute('class', 'zend-form');
$this->add(array(
'name' => 'id',
'attributes' => array(
'type' => 'hidden',
),
));
$this->add(array(
'name' => 'name',
'attributes' => array(
'type' => 'text',
),
'options' => array(
'label' => 'Name',
),
));
$this->add(array(
'name' => 'description',
'attributes' => array(
'type' => 'textarea',
),
'options' => array(
'label' => 'Description',
),
));
$this->add(array(
'name' => 'submit',
'attributes' => array(
'type' => 'submit',
'value' => 'Add',
'class' => "btn btn-success"
)
));
}
}
view:
echo $this->form($form);
Hi man,
I found a bug, the help block isn't been translated...
I fix add follow in 187 line of file TwbBundleFormRow
$this->getEscapeHtmlHelper()->__invoke(($oTranslator = $this->getTranslator()) ? $oTranslator->translate($sHelpBlock,$this->getTranslatorTextDomain()) : $sHelpBlock)
Thanks!
In the file TwbBundleFormElement.php at lines 53-57 it appears that the logic for "add-on-prepend" and "add-on-append" are the wrong way around the way I see things.
Add an option of "add-on-append" to an element actually puts the text at the start of the field, and "add-on-prepend" places the text at the end of the field.
Very nice module, by the way.
Hi,
In TwbBundleForm you expect what kind of layout do you want, and set in all elements.
My first suggestion is do the same way to TwbBundleFormCollection, this avoid i have to set in all elements the layout (if I don't use $this->form() view helper)
My second suggestion is instead you pass as parameter you can first use the option setted in the form (or collection) but the parameter can overwrite that option..
What do you think?
As you can see in http://getbootstrap.com/css/#forms-horizontal
You don't need row class, for that you can remove this line
https://github.com/neilime/zf2-twb-bundle/blob/master/src/TwbBundle/Form/View/Helper/TwbBundleForm.php#L65
For the forum elements with the column-size option and validation error, space missing between "has-error" and "col-lg-X" classes.
<div class="form-group has-errorcol-lg-6">...</div>
Hello,
In your example I see :
->add(array(
'name' => 'optionsRadios',
'type' => 'MultiCheckbox',
'options' => array(
'value_options' => array(
array('label' => '1','value' => 'option1', 'attributes' => array('id' => 'inlineCheckbox1')),
array('label' => '2','value' => 'option2', 'attributes' => array('id' => 'inlineCheckbox2')),
array('label' => '3','value' => 'option3', 'attributes' => array('id' => 'inlineCheckbox3'))
)
)
))
It's for Multicheckbox, when I do the same with Radio ? I want to have Radio inline.
Thanks
Hello i found a bug, name of label variable
diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php
index 0f70245..fa7422a 100644
--- a/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php
+++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php
@@ -41,7 +41,7 @@ class TwbBundleFormCollection extends \Zend\Form\View\Helper\FormCollection{
// Every collection is wrapped by a fieldset if needed
if($this->shouldWrap && ($sLabel = $oElement->getLabel())){
if(null !== ($oTranslator = $this->getTranslator()))$sLabel = $oTranslator->translate($label, $this->getTranslatorTextDomain());
if(null !== ($oTranslator = $this->getTranslator()))$sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain());
$sMarkup = sprintf(
'<fieldset><legend>%s</legend>%s</fieldset>',
$this->getEscapeHtmlHelper()->__invoke($sLabel),
How can I set up the module manually to load the view helpers?
Thank you.
Aegidius
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.