componentFactory = $factory; } public function buildForm(FormBuilder $builder, array $options) { $components = $this->componentFactory->getComponents(); $choices = array(); $fieldChoices = array(); foreach ($components as $k => $c) { $choices[$k] = ucwords(str_replace('_', ' ', $k)); $fieldChoices[$k] = $this->componentFactory->getRuleFields($k); } $builder ->add('component', 'choice', array('choices' => $choices)) ->add('field', 'chained_choice', array('choices' => $fieldChoices, 'link' => 'component')) ->add('rule', 'rule') ; } public function getName() { return 'politistream_corebundle_profileruletype'; } public function getDefaultOptions(array $options) { return array( 'data_class' => 'Politistream\CoreBundle\Entity\ProfileRule', ); } }