18
我想將一些使用Rails simple_form生成的表單放在一個頁面上,並使用javascript對它們進行操作。然而,simple_form爲表單中的各個輸入生成相同的ID。因此我想用我自己的替換生成的ID。Rails simple_form:自定義輸入ID
現在我有一句臺詞:
<%= f.input :id, :as => :hidden, :html => {:value => @question.id} %>
和HTML輸出(用於@ question.id = 1):
<input id="question_id" class="hidden" type="hidden" value="1" name="question[id]">
,我想:
<input id="question_id_1" class="hidden" type="hidden" value="1" name="question[id]">
question_id_1
只是一個例子。我希望能夠選擇這個ID。
我使用Rails 3和simple_form 1.5。
非常感謝。我嘗試過':html'和':html_options',但':input_html'解決了這個問題。 – mrzasa 2011-12-30 23:59:19
:input_html,:label_html,:wrapper_html將涵蓋大部分這些事情。 – 2011-12-31 02:34:53