I have a checkbox form element like this:
...
->add(
'race',
'choice',
array(
'label' => 'Racial Identity',
'choices' => array(
'American Indian or Alaskan Native' => 'American Indian or Alaskan Native',
'Asian' => 'Asian',
'Black or African American' => 'Black or African American',
'Native Hawaiian or Other Pacific Islander' => 'Native Hawaiian or Other Pacific Islander',
'White' => 'White',
),
'multiple' => true,
'expanded' => true,
)
)
...
I'm writing a test to submit this form with a couple of the options checked:
...
$form = $crawler->selectButton('Submit Application')->form(array(
'application' => array(
...
'race' => array(
'Asian',
'White',
),
...
)
));
$crawler = $client->submit($form);
When submitting the form, I get this error:
InvalidArgumentException: Input "application[race][]" cannot take "Asian" as a value (possible values: American Indian or Alaskan Native).
According to the docs on the DOM Crawler, I'm properly passing the data to the multi-dimensional form.
Here's a what the HTML looks like for the checkboxes:
<input type="checkbox" id="application_race_0" name="application[race][]" value="American Indian or Alaskan Native">
<input type="checkbox" id="application_race_1" name="application[race][]" value="Asian">
<input type="checkbox" id="application_race_2" name="application[race][]" value="Black or African American">
<input type="checkbox" id="application_race_3" name="application[race][]" value="Native Hawaiian or Other Pacific Islander">
<input type="checkbox" id="application_race_4" name="application[race][]" value="White">
Why isn't this working? It appears to think that only the first checkbox is valid.