title: Symfony Dynamic Modification of Form without Entity
body: <p>I am following the Symfony (v2.7) Cookbook recipe for <a href="http://symfony.com/doc/2.7/cookbook/form/dynamic_form_modification.html#cookbook-form-events-submitted-data" rel="nofollow">dynamic form modification</a>. What I am aiming for is displaying certain fields based on a user's radio button selection. For example, if a user wishes to filter a search based on records from the last fiscal year, he selects the "Fiscal Year" radio button from the <strong>criteriaFilter</strong> choice field type (example below), and the appropriate fields are generated. If he changes his mind and selects "Semester" instead, the fiscal year fields are replaced with the semester fields, and so on.</p>
  
  <p>Example code:</p>
  
  <pre><code>$builder    
          -&gt;add('librarian', 'entity', array(
              'class' =&gt; 'AppBundle:Staff',
              'query_builder' =&gt; function(EntityRepository $er){
                  $qb = $er-&gt;createQueryBuilder('st');
                  $qb
                      -&gt;where('st.employmentStatus = :employmentStatus')
                      -&gt;setParameter('employmentStatus', 'faclib')
                      -&gt;orderBy('st.lastName', 'DESC')
                      -&gt;getQuery();
                  return $qb;
              },
              'placeholder' =&gt; 'All Librarians',
              'required' =&gt; false
          ))
          -&gt;add('program', 'entity', array(
              'class' =&gt; 'AppBundle:LiaisonSubject',
              'query_builder'=&gt;function(EntityRepository $er){
                $qb = $er-&gt;createQueryBuilder('ls');
                $qb
                  -&gt;orderBy('ls.root, ls.lvl, ls.name', 'ASC')
                  -&gt;getQuery();
                return $qb;
              },
              'property' =&gt; 'indentedTitle',
              'placeholder' =&gt; 'All Programs',
              'required' =&gt; false,
              'label' =&gt; 'Program'
          ))
          -&gt;add('criteriaFilter', 'choice', array(
                  'expanded' =&gt; true,
                  'multiple' =&gt; false,
                  'choices' =&gt; array(
                      'academic' =&gt; 'Academic Year',
                      'fiscal' =&gt; 'Fiscal Year',
                      'semester' =&gt; 'Semester',
                      'custom' =&gt; 'Custom Range'
                  ),
              ))
              ;
  </code></pre>
  
  <p>This seems pretty straighforward based on the cookbook entry. However, <strong>the form I am creating is not bound to an entity</strong>. Therefore, fetching data via the method</p>
  
  <pre><code>$builder-&gt;addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event){
              $form = $event-&gt;getForm();
  
              //normally the entity, but NULL in this case 
              $data = $event-&gt;getData();
  ...
  </code></pre>
  
  <p>which would normally allow for calling of getter methods on entity properties returns null. So obviously this can't work in this case.</p>
  
  <p>So the question is, is there another way to dynamically generate fields inside of a form that is not tied to an entity?</p>