/** * {@inheritDoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $useFqcn = method_exists('Symfony\\Component\\Form\\AbstractType', 'getBlockPrefix'); // Symfony's Form component >=2.8 $isBugReport = $options['isBugReport']; $setChoicesAsValuesOption = $useFqcn && method_exists('Symfony\\Component\\Form\\AbstractType', 'getName'); // Symfony's Form component >=2.8 && <3.0 switch ($options['flow_step']) { case 1: $builder->add('title'); $builder->add('description', null, array('required' => false)); $defaultChoiceOptions = array(); if ($setChoicesAsValuesOption) { $defaultChoiceOptions['choices_as_values'] = true; } $choices = Topic::getValidCategories(); $builder->add('category', $useFqcn ? 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType' : 'choice', array_merge($defaultChoiceOptions, array('choices' => array_combine($choices, $choices), 'placeholder' => ''))); break; case 2: $builder->add('comment', $useFqcn ? 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TextareaType' : 'textarea', array('required' => false)); break; case 3: if ($isBugReport) { $builder->add('details', $useFqcn ? 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TextareaType' : 'textarea'); } break; } }
/** * {@inheritDoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $isBugReport = $options['isBugReport']; switch ($options['flowStep']) { case 1: $builder->add('title'); $builder->add('description', null, array('required' => false)); $choices = Topic::getValidCategories(); $builder->add('category', 'choice', array('choices' => array_combine($choices, $choices), 'empty_value' => '')); break; case 2: $builder->add('comment', 'textarea', array('required' => false)); break; case 3: if ($isBugReport) { $builder->add('details', 'textarea'); } break; } }