Skip to content

Symfony : composer update 4.4.19 > 4.4.20 occures "The value array is not valid" when submitting form with entitytype. #40483

Closed
@fodger

Description

@fodger

Symfony version(s) affected: 4.4.2

Description
After updating Symfony 4.4.19 to 4.4.20,
some forms using Entitytype class - populated with json - give the following error when handling request :


The value array is not valid. | recipients | Caused by:                                                             
Symfony\Component\Form\Exception\TransformationFailedException {#6790 ▼
  -invalidMessage: null
  -invalidMessageParameters: []
  #message: "The choices "XXXX" do not exist in the choice list."
  #code: 0
  #file: "/project/vendor/symfony/form/Extension/Core/Type/ChoiceType.php"
  #line: 183
  trace: {▼
    /project/vendor/symfony/form/Extension/Core/Type/ChoiceType.php:183 {▶}
    /project/vendor/symfony/event-dispatcher/EventDispatcher.php:264 {▶}
    /project/vendor/symfony/event-dispatcher/EventDispatcher.php:239 {▶}
    /project/vendor/symfony/event-dispatcher/EventDispatcher.php:73 {▶}
    /project/vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php:44 {▶}
    /project/vendor/symfony/form/Form.php:671 {▶}
    /project/vendor/symfony/form/Form.php:579 {▶}
    /project/vendor/symfony/form/Extension/HttpFoundation/HttpFoundationRequestHandler.php:109 {▶}
    /project/vendor/symfony/form/Form.php:493 {▶}
    ...

It works perfectly with SF 4.4.19.

Regards,

How to reproduce

  • Juste create a simple form with an empty choice list:
$form = $this->createFormBuilder()
  ->add('recipients', EntityType::class, [
      'class' => MyEntity::class,
      'translation_domain' => 'mytranslation_domain',
      'choice_label' => 'choice_label',
      'label' => 'em.texts.to',
      'multiple' => true,
      'mapped' => true,
      'choices' => $mychoices
]);
  • print in a twig using select2 lib

  • populate with a json request, make a choice and submit

Possible Solution
Patching src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php ?

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions