2012-10-24 56 views
10
<p><%= f.input :terms, :as => :boolean, :label => false, :boolean_style => :inline %> 
Accept <%= link_to "Terms of use", terms_path,:remote => true %> 
and <%=link_to "privacy Policy", privacy_path, :remote => true%></p> 

它結束了看起來像這樣Simple_form如何使接受條款複選框直列

enter image description here

什麼是排隊起來在同一行的最好方式。

回答

23

這是一個相當簡單的方法:

<%= content_for(:the_links) do %> 
    Accept <%= link_to "Terms of use", terms_path,:remote => true %> 
    and <%=link_to "privacy Policy", privacy_path, :remote => true%> 
<% end %> 

<%= simple_form_for @user do |f| %> 
    <%= f.input :email %> 
    <%= f.input :password %> 
    <%= f.input :terms, :as => :boolean, :label => content_for(:the_links)%> 
<% end%> 

the-non-styled-output

+0

這工作得很好。謝謝! – Benamir

+0

很好的使用content_for block :) – engineerDave

+0

嘿,這是'content_for'的一個很棒的技巧。很有用。 – paracycle

1

確保複選框和文字是足夠小,適合於容器內一排,然後設置display: inline;float:left;

+0

顯示:內聯不起作用,並浮動左工程,但它看起來很奇怪,因爲我的表單居中。 – Benamir

0

嘗試使用wrapper_html這樣的:

<p> 
    <%= f.input :terms, 
      :as => :boolean, 
      :label => false, 
      :boolean_style => :inline,  
      :wrapper_html => { :style => 'display: inline' } 
    %> 
    Accept <%= link_to "Terms of use", terms_path,:remote => true %> 
    and <%=link_to "privacy Policy", privacy_path, :remote => true%> 
</p> 
+0

嗯,不幸的是,仍然無法正常工作。 – Benamir

相關問題