public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('receiveEmail', CheckboxType::class, ['label' => 'Check to receive e-mail, uncheck to stop']); $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { $form = $event->getForm(); if (null != $this->options && array_key_exists('skill_required', $this->options) && $this->options['skill_required']) { $form->add('skills', 'skills', array('constraints' => array(new Count(array('min' => '1', 'minMessage' => 'At least one skill is required'))))); } if (null != $this->options && array_key_exists('focus_required', $this->options) && $this->options['focus_required']) { $form->add('focuses', 'focuses', array('constraints' => array(new Count(array('min' => '1', 'minMessage' => 'At least one focus is required'))))); } }); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('organization', new OrganizationType($this->options)); }