Selecting invalid choice values of a select form field in a Symfony functional test

Published on 2022-08-19 • Modified on 2022-08-19

This snippet shows how to select an invalid choice value of a select form field in a Symfony functional test. Indeed, if you try to choose an invalid option in your test, an exception is raised, and your test will fail. So, you must disable this check to test that your server-side validation of your form is working correctly.


$form['my_select']->disableValidation()->select('foobar');

 More on Stackoverflow   Read the doc  Random snippet

  Work with me!


Call to action

Did you like this post? You can help me back in several ways: (use the "reply" link on the right to comment or to contact me )

Thank you for reading! And see you soon on Strangebuzz! 😉

COil