browser icon indicating copy to clipboard operation
browser copied to clipboard

Support input with `form` attribute

Open maelanleborgne opened this issue 10 months ago • 1 comments

Description

Hello,

Just noticed that performing a click on a button linked to a specific form (with the form attribute) does not seem to be supported right now.

In addition, the formaction attribute is also ignored, though I don't think it's widely used so not really a priority.

Reproducer

Running this will submit on /another-action instead of /action

<form id="my-form" action="/action"></form>

<form action="/another-action">
    <button type="submit" form="my-form">Click me</button>
</form>
$this->browser()
// ...
    ->click('Click me')
;

Suggestion

I'd be happy to help, though I don't know where would the fix be done :

  • \Zenstruck\Browser\Session\KernelSession::formFor ?
  • \Zenstruck\Dom\Node\Form\Element::form ?
  • Directly in the click() method (though that would leave aside the fields ...)

maelanleborgne avatar Feb 21 '25 13:02 maelanleborgne

hello,

I think we should also support formaction, I just lost 30 min figuring out why my test was not working 😅

sadly, I don't think this could be fixed in this library without any hack, it seems that behat/mink is responsible of this.

any thought @kbond?

nikophil avatar Aug 27 '25 13:08 nikophil