#156 ✓invalid
ronin

filling array fields does not work

Reported by ronin | February 7th, 2009 @ 04:08 PM

I have html with two checkboxes with the same name


<input id="option_1" name="options[]" type="checkbox" value="1" />
<label for="option_1">Option 1</label>
<input id="option_2" name="options[]" type="checkbox" value="2" />
<label for="option_2">Option 2</label>

When I try to check both these fields with webrat


check('Option 1')
check('Option 2')

i get ["12"] in params[:options] instead of ["1", "2"].

Comments and changes to this ticket

  • Bryan Helmkamp

    Bryan Helmkamp February 8th, 2009 @ 09:02 PM

    • State changed from “new” to “invalid”

    Hey Ronin,

    Thanks for providing a boiled-down example case. I've added a spec to verify this functionality is working as expected in the latest webrat:

    http://github.com/brynary/webrat...

    Something else might be causing a problem, but I don't think it's this. Can you please make sure you're on the latest Webrat?

    Cheers,

    -Bryan

  • ronin

    ronin February 9th, 2009 @ 04:20 AM

    I figured out this is because file fields. When I submit the form with file attached then I get ["12"]. When the file field is empty I get correct value.

  • Paul Battley

    Paul Battley July 28th, 2009 @ 06:06 AM

    This is not a bug in Webrat. It's a bug in Rails, in ActionController::Integration::Session#multipart_requestify. When Rails builds the headers for a multipart request (which happens when a file is attached), it doesn't handle arrays properly. This only affects integration tests.

    I've written a patch that works against Rails 2.3.2 http://gist.github.com/157056 and I'll try to get a fix into Rails itself.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Tags

Pages