The value "false" for the "choices_as_values" option is deprecated since version 2.8 and will not be supported anymore in 3.0
Closed this issue · 2 comments
I get this deprecation warning with a Symfony 2.8 project even when I use the master branch of the bundle:
The value "false" for the "choices_as_values" option of the "choice" form type (Symfony\Component\Form\Extension\Core\Type\ChoiceType) is deprecated since version 2.8 and will not be supported anymore in 3.0. Set this option to "true" and flip the contents of the "choices" option instead.
When I add a MoneyType field to a form like this:
use Symfony\Component\Form\AbstractType;
use Tbbc\MoneyBundle\Form\Type\MoneyType;
...
class ServiceFormType extends AbstractType
{
$builder
->add(
'price',
MoneyType::class,
array(
'required' => false,
)
)
...
;
}
This makes AFAIK this bundle not really compatible with Symfony 3.0.
I can get rid of this warning changing Tbbc\MoneyBundle\Form\Type\CurrencyType.php
and adding choices_as_values
to true like this:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$choiceList = array();
foreach ($options["currency_choices"] as $currencyCode) {
$choiceList[$currencyCode] = $currencyCode;
}
$builder->add('tbbc_name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
"choices" => $choiceList,
**"choices_as_values" => true,**
"preferred_choices" => array($options["reference_currency"]),
));
$builder->addModelTransformer(new CurrencyToArrayTransformer());
}
I could provide a PR if you want and if you tell me which branch should I point to.
Thanks.
Ping @geekdevs
@enekochan You should just ignore this deprecation message. It is only there because ChoiceType on symfony 2.8 uses choices_as_values
internally. Once you upgrade to 3.0 it will be automatically gone. Also, we cannot add "choices_as_values=true" because it would break the bundle for symfony 3.0.
Oh, I didn't know that :) And I see now that as Currency uses the same values for id and value ('EUR' for example) it won't affect the resulting select. Thanks!