I’m trying to combine radio buttons and text_field for a single value :
= f.radio_button :system, "bacteria"
Bacteria
= f.radio_button :system, "mammalian"
Mammalian
= f.radio_button :system, "yeast"
Yeast
= f.radio_button :system, "insect"
Insect
= f.radio_button :system, "other"
Other:
= f.text_field :system, class:"input-small"
When I submit, nothing happens because a blank value is given in params even if a radio is checked (I think it considers the text field).
I tried to give another name to the text_field, and replaced the :system value in the controller after updating, but it looks like a dirty way…
Do you have any cleaner ideas ?
Here you can not directly mix radio_button and text_field together for the same field.
I think you can define one extra radio_button field that will be hidden and whose value will get updated when user enters into text_field.
In above you will be writing onchange event on text_field and whenever value gets entered inside text_field it will set hidden radio_button’s value to the text_field_value.
Above code is just to give idea how to deal with issue and will not work just as it is .. 🙂