您能否幫助我設置這個simple_form的格式?使用css,twitter-bootstrap和simple_form爲單個布爾值分組複選框
我使用這種形式:
<%= simple_form_for @my_model, :html => { :class => 'form-horizontal'} do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :some_text, :input_html => {:class => "span6", :rows => 2}%>
<%= f.input :a_description, :input_html => {:class => "span6", :rows => 2}%>
<%= f.input :boolean1%>
<%= f.input :boolean2%>
<%= f.input :boolean3%>
<%= f.input :boolean4%>
<%= f.input :boolean5%>
<%= f.input :boolean6%>
<%= f.input :boolean7%>
<%= f.input :boolean8%>
<%= f.input :id, :as => :hidden, :input_html => { :value => @my_model.id }%>
</div>
<div class="form-actions">
<%= f.button :submit, :class => 'btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
special_path, :class => 'btn' %>
</div>
<% end %>
我想爲複選框的兩列中,每個垂直堆疊在每列4項的複選框,以顯示布爾值。
像
Some text: [input]
A description: [input]
bool1 bool5
bool2 bool6
bool3 bool7
bool4 bool8
我克隆Git倉庫在這裏http://simple-form-bootstrap.plataformatec.com.br/articles/new,看了看代碼,運行它,我看到它的工作原理。
但是...它適用於存儲在字符串中的一系列複選框選項。我有一個具有8個布爾值的模型,並且無法理解如何在使用rails,css,twitter-bootstrap和simple_form的表單中將它們正確分組。
我讀過這個SO帖子:Make all input fields on the same line
...這一個:Adding controls inline with simple_form, nested_form and Twitter Bootstrap in Rails
...但他們似乎並不適合我的特殊情況,我的想法去嘗試。
請嘗試將您的答案關注於一個特定的代碼示例,該示例演示如何以某種分組方式佈局各個布爾值的複選框。
在此先感謝!
哇。如此基礎。效果很好。謝謝。想想我到這裏去了多遠的地方有點尷尬。 –