Простая форма как сделать флажок принять условия встроенным



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


В конечном итоге это выглядит так



Введите описание изображения здесь



Как лучше всего выстроить их в одну линию?

502   3  

3 ответов:

Вот довольно простой способ:

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

-не-стилизованный-выход

Убедитесь, что флажок и текст достаточно малы, чтобы поместиться в одной строке внутри контейнера, затем установите display: inline; или float:left;

Попробуйте использовать 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>

Comments

    Ничего не найдено.