Simple_form如何使内联接受条件复选框

时间:2012-10-24 16:49:48

标签: html css ruby-on-rails twitter-bootstrap simple-form

<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>

最终看起来像这样

enter image description here

在同一条线上排列它们的最佳方法是什么。

3 个答案:

答案 0 :(得分: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

答案 1 :(得分:1)

确保复选框和文字足够小以容纳容器内的一行,然后设置display: inline;float:left;

答案 2 :(得分: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>
相关问题