Skip to content

Commit ae03fdb

Browse files
committed
[#3075] Moving new Form::disableValidation DomCrawler details into the component
The idea is to keep the book chapter to more main-stream details and put longer details into the component docs
1 parent 8a91f15 commit ae03fdb

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

book/testing.rst

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -671,21 +671,10 @@ 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');
674+
.. tip::
685675

686-
// Disable validation for the whole form
687-
$form->disableValidation();
688-
$form['country']->select('Invalid value');
676+
If you purposefully want to select "invalid" select/radio values, see
677+
:ref:`components-dom-crawler-invalid`.
689678

690679
.. tip::
691680

components/dom_crawler.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ and uploading files::
340340
// even fake a file upload
341341
$form['registration[photo]']->upload('/path/to/lucas.jpg');
342342

343+
Using the Form Data
344+
...................
345+
343346
What's the point of doing all of this? If you're testing internally, you
344347
can grab the information off of your form as if it had just been submitted
345348
by using the PHP values::
@@ -375,5 +378,26 @@ directly::
375378
// submit that form
376379
$crawler = $client->submit($form);
377380

381+
.. _components-dom-crawler-invalid:
382+
383+
Selecting Invalid Choice Values
384+
...............................
385+
386+
.. versionadded:: 2.4
387+
The :method:`Symfony\\Component\\DomCrawler\\Form::disableValidation`
388+
method was added in Symfony 2.4.
389+
390+
By default, choice fields (select, radio) have internal validation activated
391+
to prevent you from setting invalid values. If you want to be able to set
392+
invalid values, you can use the ``disableValidation()`` method on either
393+
the whole form or specific field(s)::
394+
395+
// Disable validation for a specific field
396+
$form['country']->disableValidation()->select('Invalid value');
397+
398+
// Disable validation for the whole form
399+
$form->disableValidation();
400+
$form['country']->select('Invalid value');
401+
378402
.. _`Goutte`: https://github.com/fabpot/goutte
379403
.. _Packagist: https://packagist.org/packages/symfony/dom-crawler

0 commit comments

Comments
 (0)