ux icon indicating copy to clipboard operation
ux copied to clipboard

Cannot submit values in a WebTestCase to test a Symfony UX Autocomplete field if the relation is ManyToMany

Open 4d4ch4u32 opened this issue 4 months ago • 0 comments

I have a form with a AutoComplete field for a ManyToMany relation:

$builder
    ->add('categories', CategoryAutocompleteField::class, [
        'label'        => 'Kategorie(n)',
        'required'     => true,
        'class'        => Category::class,
        'autocomplete' => true,
        'multiple'     => true,
        'attr'         => [
            'placeholder' => 'Kategorie(n) wählen',
        ],
    ])
...

I try to submit the form in a WebTestCase:

    $client->submitForm('Programm erstellen', [
        'program[title]'           => 'Unit-Test 1',
        'program[description]'     => 'Unit-Test Description',
        'program[durationMinutes]' => 120,
        'program[categories]' => [1],
        'program[startLocation]'   => 1,
        'program[endLocation]'     => 4,
        'program[enabled]'         => true,
    ]);

When I run the test, I get the erorr InvalidArgumentException: Input "program[categories]" cannot take "1" as a value (possible values: "")..

4d4ch4u32 avatar Oct 11 '24 20:10 4d4ch4u32