I want to put several forms generated with Rails simple_form on a one page, and operate on them with javascript. However simple_form generated same ids for respective inputs in forms. Thus I want to replace generated id with my own.
Now I have a line:
<%= f.input :id, :as => :hidden, :html => {:value => @question.id} %>
and HTML output (for @question.id=1):
<input id="question_id" class="hidden" type="hidden" value="1" name="question[id]">
and I want to get:
<input id="question_id_1" class="hidden" type="hidden" value="1" name="question[id]">
question_id_1
is just an example. I want to be able to choose this id.
I use Rails 3 and simple_form 1.5.
You're almost there.
The trick is in specifying the :input_html
.
<%= f.input :id, :as => :hidden, :input_html => { :value => @question.id, :id => "question_id_1" } %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With