Simple_form how to make accept terms checkbox inline

十年热恋 提交于 2019-11-30 08:59:45

Here's a rather simple way:

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

Ensure the checkbox and text are small enough to fit in one row inside the container, then set display: inline; or float:left;

Try using wrapper_html like this:

<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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!