flip value for 'other'

This commit is contained in:
nobohan 2018-04-11 17:48:31 +02:00
parent ed526fa8ea
commit 654f7b4d26

View File

@ -28,8 +28,10 @@ class ChoiceWithOtherType extends AbstractType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
//$otherValueLabel = $options['other_value_label'];
//add an 'other' entry in choices array
$options['choices']['_other'] = $this->otherValueLabel;
$options['choices'][$this->otherValueLabel] = '_other';
//ChoiceWithOther must always be expanded
$options['expanded'] = true;
// adding a default value for choice
@ -50,6 +52,7 @@ class ChoiceWithOtherType extends AbstractType
$resolver
->setRequired(array('choices'))
->setAllowedTypes('choices', array('array'))
//->setDefault('other_value_label', null)
->setDefaults(array(
'multiple' => false,
))