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

@@ -4,10 +4,12 @@ namespace Chill\CustomFieldsBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
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
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*
*/
@@ -24,7 +26,7 @@ class ChoiceWithOtherType extends AbstractType
/* (non-PHPdoc)
* @see \Symfony\Component\Form\AbstractType::buildForm()
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options)
{
//add an 'other' entry in choices array
$options['choices']['_other'] = $this->otherValueLabel;
@@ -32,17 +34,17 @@ class ChoiceWithOtherType extends AbstractType
$options['expanded'] = true;
// adding a default value for choice
$options['empty_data'] = null;
$builder
->add('_other', 'text', array('required' => false))
->add('_choices', 'choice', $options)
;
->add('_other', TextType::class, array('required' => false))
->add('_choices', ChoiceType::class, $options)
;
}
/* (non-PHPdoc)
* @see \Symfony\Component\Form\AbstractType::configureOptions()
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setRequired(array('choices'))
@@ -57,4 +59,4 @@ class ChoiceWithOtherType extends AbstractType
{
return 'choice_with_other';
}
}
}