mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 21:34:59 +00:00
fix deprecations: use fqcn instead of 'choices'
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user