Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

submit_form should be able to handle multiple checkbox values #252

Open
oalders opened this issue Jul 26, 2018 · 3 comments
Open

submit_form should be able to handle multiple checkbox values #252

oalders opened this issue Jul 26, 2018 · 3 comments

Comments

@oalders
Copy link
Member

oalders commented Jul 26, 2018

If submit_form gets an arrayref it should re-use the logic in tick of cycling through the form inputs by that name and checking possible_values. As it stands it will only try to set the value on the first checkbox in a group. If the value submitted does not match the possible values of the first checkbox you get a very confusing Illegal value for 'foo' for field 'bar' error message.

Yes, you can solve this via tick and untick, but you should also just be able to submit checkbox values directly via submit_form, as you can with other form fields.

As it stands, given the form:

<form>
  <input type="checkbox" name="foo" value="bar">
  <input type="checkbox" name="foo" value="qux">
  <submit>
</form>

You can submit via:

$mech->submit_form( with_fields => { foo => ['bar'] } ); # works
$mech->submit_form( with_fields => { foo => ['qux'] } ); # doesn't work
$mech->submit_form( with_fields => { foo => ['bar','qux'] } ); # doesn't work
$mech->submit_form( with_fields => { foo => [undef, 'qux'] } ); # doesn't work
$mech->submit_form( with_fields => { foo => ['bar', undef] } ); # works
@oalders oalders changed the title submit_form should be able to handle multiple checkbox values submit_form should be able to handle multiple checkbox values Jul 26, 2018
@oalders oalders changed the title submit_form should be able to handle multiple checkbox values submit_form should be able to handle multiple checkbox values Jul 26, 2018
@petdance
Copy link
Contributor

Yes, please. This would be tremendous.

@simbabque
Copy link
Contributor

While I'm here, I could give this a try too.

@oalders
Copy link
Member Author

oalders commented Oct 15, 2018

@simbabque please do!

@oalders oalders mentioned this issue Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants