Reputation: 75
I made a request for a form but cannot define ChoiceType for select option for Actions Field.
$form = $this->createFormBuilder()
->add('title', TextType::class, array('label' => 'Label1', 'attr' => ['class'=>'form-control']))
->add('actions', ChoiceType::class, array('a' => 'Option 1', 'b' => 'Option 2','c' => 'Option 3'))
->add('save', SubmitType::class, array('label' => 'Send', 'attr' => [
'class' => 'btn btn-primary action-save'
]))
->getForm();
Any Ideas?
Upvotes: 0
Views: 101
Reputation:
https://symfony.com/doc/current/reference/forms/types/choice.html#choices
$form = $this->createFormBuilder()
->add('title', TextType::class, array('label' => 'Label1', 'attr' => ['class'=>'form-control']))
->add('actions', ChoiceType::class, array(
'choices' => array('a' => 'Option 1', 'b' => 'Option 2','c' => 'Option 3')
))
->add('save', SubmitType::class, array('label' => 'Send', 'attr' => [
'class' => 'btn btn-primary action-save'
]))
->getForm();
Upvotes: 2