Skip to content

Commit b944124

Browse files
committed
Added documentation about disabling internal validation of DomCrawler forms.
1 parent 72b690f commit b944124

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

book/testing.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,22 @@ their type::
671671
// Upload a file
672672
$form['photo']->upload('/path/to/lucas.jpg');
673673

674+
.. versionadded:: 2.4
675+
The :method:`Symfony\\Component\\DomCrawler\\Form::disableValidation`
676+
method was added in Symfony 2.4.
677+
678+
By default, choice fields (select, radio) have internal validation activated
679+
to prevent you from setting invalid values. If you want to be able to set
680+
invalid values, you can use the ``disableValidation()`` method on either
681+
the whole form or specific field(s)::
682+
683+
// Disable validation for a specific field
684+
$form['country']->disableValidation()->select('Invalid value');
685+
686+
// Disable validation for the whole form
687+
$form->disableValidation();
688+
$form['country']->select('Invalid value');
689+
674690
.. tip::
675691

676692
You can get the values that will be submitted by calling the ``getValues()``

0 commit comments

Comments
 (0)