Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand correctly you need to modify your form dynamically.</p> <p>Take a look here: <a href="http://symfony.com/doc/master/cookbook/form/dynamic_form_modification.html" rel="nofollow">How to Dynamically Modify Forms Using Form Events</a></p> <p><strong>UPDATE</strong></p> <p>To pass options to your form you can modify the form this way:</p> <pre><code>&lt;?php namespace CD\BoutiqueBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; class UserType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $myCustomVar = $options['foo']; $builder -&gt;add('nom', 'text') -&gt;add('prenom', 'text') -&gt;add('mail', 'text') -&gt;add('fb_id','hidden',array('data'=&gt;'null')) -&gt;add('pass', 'repeated', array('type' =&gt; 'password', 'invalid_message' =&gt; 'The password fields must match.', 'first_options' =&gt; array('label' =&gt; 'Mot de passe'), 'second_options' =&gt; array('label' =&gt; 'Confirmer le mot de passe'))) -&gt;add('tel', 'text', array('required' =&gt; false)) -&gt;add('adresse', 'text') -&gt;add('code_postal', 'text') -&gt;add('ville', 'text') -&gt;add('tel', 'text') -&gt;add('date_naissance', 'birthday', array('widget' =&gt; 'choice', 'years' =&gt; range(1933,2013,1), 'months' =&gt; range(1,12,1), 'days' =&gt; range(1,31,1))); } public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver-&gt;setDefaults(array( 'data_class' =&gt; 'CD\ConfigBundle\Entity\User', 'foo' =&gt; 'bar' )); } public function getName() { return 'usertype'; } } </code></pre> <p>As you can see in setDefaultOptions method you must declare the custom option. Then in your controller you can instantiate your form this way:</p> <pre><code>$myForm = $this-&gt;createForm(new UserType(), $entity, array('foo' =&gt; 'baz')); </code></pre> <p>Hope this helps</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload