Open
Description
Description
If I got a formfield like:
$form->add('status', ChoiceType::class, [
'label' => 'Status',
'choices' => [
'error' => 'Error',
'ok' => 'This is ok'
]
]);
Then in my test I should be able to do:
$form = $crawler->form();
$form['form[status]']->selectByText('This is ok');
Today I must do this by having an outside algorithm:
private function formSelectChoose(ChoiceFormField $formField, string $value, Crawler $crawler )
{
$name = $formField->getName();
$select = $crawler->filter('select[name="'.$name.'"]')->first();
foreach($select->filter('option') as $option) {
print $option->textContent ."\n";
if (trim($option->textContent) == $value) {
$formField->select($option->getAttribute('value'));
return;
}
}
throw new \Exception("Could not find option $value");
}
It would be great to be able to do this directly on the ChoiceFormField.