stouset/twitter_bootstrap_form_for

Select tags broken

Closed this issue · 9 comments

Select tags with the following definition:

twitter_bootstrap_form_for @model do |f|
  f.select :field_name, [['one',1],['Two',2]]

do not render properly. It appears that the options array is being put into the label field.

<div class="clearfix" id="model_field_name_input"><label for="model_field_name">one1two2</label><div class="input"><select id="model_field_name" name="model[field_name]"></select></div></div>

Per the README, the second argument is the label.

Then what is the preferred way of doing drop-downs?

i cannot find any examples and everything I try doing ends up with the data in the label.

The above code was unmodified from a normal form_for's select_tag which is why I am wondering. I thought this would be a drop-in replacement (with extensions).

twitter_bootstrap_form_for @model do |f|
  f.select :field_name, 'Label', [['one',1],['Two',2]]

I've got a documented example of a date_select in the README. I can add an example of other _select methods as well. Basically, in every form helper, the first parameter is the attribute, the second parameter is the label, and any other arguments that the method originally took are shifted over to the third argument and so on.

bugger I thought I tried that. Ok, thanks for the help!

I also managed to miss the select example in the readme...must be going blind.

Aha, I think I know why I missed the date select in the readme, the image used in the example 'this code is produces this image' doesn't have the date select so I scanned the image, didn't see the select so didn't check the code in enough detail.

No problem. You're not the first person who's had that confusion. I've considered making the label the last non-hash param, but this felt more intuitive (even though it prevents automatic label naming on selects).

Whoops. I'll update the image. facepalm