Skip to content

submit_form should be able to handle multiple checkbox valuesΒ #252

@oalders

Description

@oalders

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions