#144 open
Chris Flipse

Default selecting from every <optgroup> in a select

Reported by Chris Flipse | January 24th, 2009 @ 06:09 PM | in 0.5

I can point to exactly where this bug is occuring, I just don't know enough XPath to fix it.

Given the following select element in a form:


<select name="pets">
  <option value="">Pick one ...</option>
  <optgroup label="dogs">
    <option value="akita">Akita</option>
    <option value="sheltie">Sheltie</option>
  </optgroup>
  <optgroup label="cats">
    <option value="siamese">Siamese</option>
    <option value="shorthair">Shorthair</option>
  </optgroup>
  <optgroup label="fish">
    <option value="goldfish">Goldfish</option>
  </optgroup>
</select>

and a bunch of other stuff in the form. If I totally ignore the field, it's supposed to just choose the first value in the form, so there's something submitted.

The problem is that it chooses all of the "first" values in the form, and I end up with a param that looks like


 { :pets => "akitasiamesegoldfish" }

Which, depending on the model, doesn't even come close to validating. ;)

I'm pretty sure the bug comes in from line 385 of webrat/core/elements/field.rb but unfortunately, I don't know enough XPath to hand you a nice fix for it.

Comments and changes to this ticket

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