fix deprecations: use choices_as_values=true and flip content of the choice options

This commit is contained in:
nobohan 2018-04-04 17:50:23 +02:00
parent 9951a5d765
commit 23dd4ec48b
6 changed files with 23 additions and 15 deletions

View File

@ -254,7 +254,8 @@ class CustomFieldsGroupController extends Controller
'csrf_protection' => false
))
->add('type', ChoiceType::class, array(
'choices' => $fieldChoices
'choices' => array_combine(array_values($fieldChoices),array_keys($fieldChoices)),
'choices_as_values' => true
))
->add('customFieldsGroup', HiddenType::class)
->add('submit', SubmitType::class);

View File

@ -124,8 +124,9 @@ class CustomFieldChoice extends AbstractCustomField
'expanded' => true,
'multiple' => false,
'choices' => array(
'1' => 'Multiple',
'0' => 'Unique'),
'Multiple' => '1',
'Unique' => '0'),
'choices_as_values' => true,
'empty_data' => '0',
'label' => 'Multiplicity'
))
@ -133,16 +134,18 @@ class CustomFieldChoice extends AbstractCustomField
'expanded' => true,
'multiple' => false,
'choices' => array(
'1' => 'Expanded',
'0' => 'Non expanded'),
'Expanded' => '1',
'Non expanded' => '0'),
'choices_as_values' => true,
'empty_data' => '0',
'label' => 'Choice display'
))
->add(self::ALLOW_OTHER, ChoiceType::class, array(
'label' => 'Allow other',
'choices' => array(
'0' => 'No',
'1' => 'Yes'),
'No' => '0',
'Yes' => '1'),
'choices_as_values' => true,
'empty_data' => '0',
'expanded' => true,
'multiple' => false

View File

@ -111,8 +111,9 @@ class CustomFieldLongChoice extends AbstractCustomField
}
return $builder->add(self::KEY, ChoiceType::class, array(
'choices' => $choices,
'label' => 'Options key'
'choices' => array_combine(array_values($choices),array_keys($choices)),
'label' => 'Options key',
'choices_as_values' => true
));
}

View File

@ -124,9 +124,10 @@ class CustomFieldText extends AbstractCustomField
->add(self::MAX_LENGTH, 'integer', array('empty_data' => 256))
->add(self::MULTIPLE_CF_INLINE, ChoiceType::class, array(
'choices' => array(
'1' => 'Multiple boxes on the line',
'0' => 'One box on the line'
'Multiple boxes on the line' => '1',
'One box on the line' => '0'
),
'choices_as_values' => true,
'label' => 'Box appearance',
'expanded' => True
))

View File

@ -104,10 +104,11 @@ class CustomFieldTitle extends AbstractCustomField
return $builder->add(self::TYPE, ChoiceType::class,
array(
'choices' => array(
self::TYPE_TITLE => 'Main title',
self::TYPE_SUBTITLE => 'Subtitle'
'Main title' => self::TYPE_TITLE,
'Subtitle' => self::TYPE_SUBTITLE
),
'label' => 'Title level'
'label' => 'Title level',
'choices_as_values' => true
)
);
}

View File

@ -47,7 +47,8 @@ class CustomFieldsGroupType extends AbstractType
$builder
->add('name', 'translatable_string')
->add('entity', ChoiceType::class, array(
'choices' => $entities
'choices' => array_combine(array_values($entities),array_keys($entities)),
'choices_as_values' => true
))
;