symfony 2, form_rest(form) shows collection fields -
my form has 3 collection fields:
$builder->add('affiliates', 'collection', array( 'type' => new affiliateform(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'options' => array( 'affiliate_types' => $options['affiliate_types'], 'business_types' => $options['business_types'], ), )); $builder->add('other_businesses', 'collection', array( 'type' => new otherbusinessform(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, )); $builder->add('welfare_activities', 'collection', array( 'type' => new welfareactivityform(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'options' => array( 'welfare_activity_types' => $options['welfare_activity_types'], ), ));
in template show each subform field separately 1 one, below:
<td class="t1c5" >{{ form_widget(affiliate.location) }} {{ form_errors(affiliate.location) }}</td>
at end of form did:
{{ form_rest(form) }}
but causes display following words @ end of form, when given collection empty: "affiliates", "other businesses", "welfare activities". question is:
- why words displayed on form?
i can following avoid above issue:
<div style="display:none;">{{ form_rest(form) }}</div>
is correct way of dealing problem (maybe can make field hidden or whatever)?
thank you.
those words displayed on form because forget :
{{ form_label(affiliate.location) }} … …
according doc :
form_rest(view, variables)
this renders fields have not yet been rendered given form. it's idea have somewhere inside form it'll render hidden fields , make fields forgot render more obvious (since it'll render field you).
Comments
Post a Comment