Skip to content

[DomCrawler] Support for fallback hidden fields #11689

@aik099

Description

@aik099

Consider following form:

<form action="/">
    <input type="hidden" name="option" value="default">
    <input type="radio" name="option" value="A">
    <input type="radio" name="option" value="B">
    <input type="hidden" name="settings[1]" value="0">
     <input type="checkbox" name="settings[1]" value="1" id="setting-1">
    <button>klickme</button>
</form>

Form generated by CakePHP and Laravel automatically. This works the way that when no radio button was selected or checkbox was checked a value from hidden field with same name attribute used in POST and getValue method of corresponding FormField in DomCrawler.

Right now this results in Fatal Error with radio button (because hidden field which is discovered first in considered as radio button, when a radio button with same name is found), see Behat/Mink#349:

Fatal error: Call to undefined method Symfony\Component\DomCrawler\Field\InputFormField::addChoice() in ./vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php on line 412

and has no effect (default value from hidden field isn't used), when we're dealing with checkbox, see Behat/Mink#595 .

Related issues:

  • Behat/Mink#349
  • Behat/Mink#595

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions