fix deprecations: use fqcn instead of 'choices'

This commit is contained in:
nobohan 2018-04-04 15:55:45 +02:00
parent 65e7354437
commit b84ee91652
7 changed files with 100 additions and 92 deletions

View File

@ -6,6 +6,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
@ -252,7 +253,7 @@ class CustomFieldsGroupController extends Controller
'action' => $this->generateUrl('customfield_new'), 'action' => $this->generateUrl('customfield_new'),
'csrf_protection' => false 'csrf_protection' => false
)) ))
->add('type', 'choice', array( ->add('type', ChoiceType::class, array(
'choices' => $fieldChoices 'choices' => $fieldChoices
)) ))
->add('customFieldsGroup', HiddenType::class) ->add('customFieldsGroup', HiddenType::class)

View File

@ -31,6 +31,7 @@ use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer;
use Symfony\Bridge\Twig\TwigEngine; use Symfony\Bridge\Twig\TwigEngine;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\Translator;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/** /**
* *
@ -110,7 +111,7 @@ class CustomFieldChoice extends AbstractCustomField
$options['expanded'] = $customFieldOptions[self::EXPANDED]; $options['expanded'] = $customFieldOptions[self::EXPANDED];
$builder->add( $builder->add(
$builder->create($customField->getSlug(), 'choice', $options) $builder->create($customField->getSlug(), ChoiceType::class, $options)
->addModelTransformer(new CustomFieldDataTransformer($this, $customField)) ->addModelTransformer(new CustomFieldDataTransformer($this, $customField))
); );
} }
@ -119,7 +120,7 @@ class CustomFieldChoice extends AbstractCustomField
public function buildOptionsForm(FormBuilderInterface $builder) public function buildOptionsForm(FormBuilderInterface $builder)
{ {
$builder $builder
->add(self::MULTIPLE, 'choice', array( ->add(self::MULTIPLE, ChoiceType::class, array(
'expanded' => true, 'expanded' => true,
'multiple' => false, 'multiple' => false,
'choices' => array( 'choices' => array(
@ -128,7 +129,7 @@ class CustomFieldChoice extends AbstractCustomField
'empty_data' => '0', 'empty_data' => '0',
'label' => 'Multiplicity' 'label' => 'Multiplicity'
)) ))
->add(self::EXPANDED, 'choice', array( ->add(self::EXPANDED, ChoiceType::class, array(
'expanded' => true, 'expanded' => true,
'multiple' => false, 'multiple' => false,
'choices' => array( 'choices' => array(
@ -137,7 +138,7 @@ class CustomFieldChoice extends AbstractCustomField
'empty_data' => '0', 'empty_data' => '0',
'label' => 'Choice display' 'label' => 'Choice display'
)) ))
->add(self::ALLOW_OTHER, 'choice', array( ->add(self::ALLOW_OTHER, ChoiceType::class, array(
'label' => 'Allow other', 'label' => 'Allow other',
'choices' => array( 'choices' => array(
'0' => 'No', '0' => 'No',

View File

@ -27,6 +27,7 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option;
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer; use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer;
use Symfony\Bridge\Twig\TwigEngine; use Symfony\Bridge\Twig\TwigEngine;
use Chill\MainBundle\Form\Type\Select2ChoiceType; use Chill\MainBundle\Form\Type\Select2ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/** /**
* *
@ -109,7 +110,7 @@ class CustomFieldLongChoice extends AbstractCustomField
$choices[$key] = $key; $choices[$key] = $key;
} }
return $builder->add(self::KEY, 'choice', array( return $builder->add(self::KEY, ChoiceType::class, array(
'choices' => $choices, 'choices' => $choices,
'label' => 'Options key' 'label' => 'Options key'
)); ));

View File

@ -28,6 +28,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Bundle\TwigBundle\TwigEngine; use Symfony\Bundle\TwigBundle\TwigEngine;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/** /**
* @author Julien Fastré <julien.fastre@champs-libres.coop> * @author Julien Fastré <julien.fastre@champs-libres.coop>
@ -121,7 +122,7 @@ class CustomFieldText extends AbstractCustomField
{ {
return $builder return $builder
->add(self::MAX_LENGTH, 'integer', array('empty_data' => 256)) ->add(self::MAX_LENGTH, 'integer', array('empty_data' => 256))
->add(self::MULTIPLE_CF_INLINE, 'choice', array( ->add(self::MULTIPLE_CF_INLINE, ChoiceType::class, array(
'choices' => array( 'choices' => array(
'1' => 'Multiple boxes on the line', '1' => 'Multiple boxes on the line',
'0' => 'One box on the line' '0' => 'One box on the line'

View File

@ -27,6 +27,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Bundle\TwigBundle\TwigEngine; use Symfony\Bundle\TwigBundle\TwigEngine;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
class CustomFieldTitle extends AbstractCustomField class CustomFieldTitle extends AbstractCustomField
{ {
@ -100,7 +101,7 @@ class CustomFieldTitle extends AbstractCustomField
public function buildOptionsForm(FormBuilderInterface $builder) public function buildOptionsForm(FormBuilderInterface $builder)
{ {
return $builder->add(self::TYPE, 'choice', return $builder->add(self::TYPE, ChoiceType::class,
array( array(
'choices' => array( 'choices' => array(
self::TYPE_TITLE => 'Main title', self::TYPE_TITLE => 'Main title',

View File

@ -8,6 +8,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
class CustomFieldsGroupType extends AbstractType class CustomFieldsGroupType extends AbstractType
@ -45,7 +46,7 @@ class CustomFieldsGroupType extends AbstractType
$builder $builder
->add('name', 'translatable_string') ->add('name', 'translatable_string')
->add('entity', 'choice', array( ->add('entity', ChoiceType::class, array(
'choices' => $entities 'choices' => $entities
)) ))
; ;

View File

@ -4,6 +4,8 @@ namespace Chill\CustomFieldsBundle\Form\Type;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
/** /**
* Return a choice widget with an "other" option * Return a choice widget with an "other" option
@ -34,8 +36,8 @@ class ChoiceWithOtherType extends AbstractType
$options['empty_data'] = null; $options['empty_data'] = null;
$builder $builder
->add('_other', 'text', array('required' => false)) ->add('_other', TextType::class, array('required' => false))
->add('_choices', 'choice', $options) ->add('_choices', ChoiceType::class, $options)
; ;
} }