public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('is_all', 'checkbox', array('label' => 'Check all', 'required' => false)); if ($this->isShowType) { $builder->add('rebalance_type', 'choice', array('choices' => Job::rebalanceTypeChoicesForSelect(), 'required' => true)); } $factory = $builder->getFormFactory(); $choices = $this->clientValueIds; $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($factory, $choices) { $form = $event->getForm(); $form->add($factory->createNamed('client_value', 'choice', null, array('choices' => $choices, 'multiple' => true, 'expanded' => true))); }); }