2012-10-24 14 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> 

kończy się patrząc jak tenSimple_form jak zrobić Akceptuję regulamin checkbox inline

enter image description here

Jaki jest najlepszy sposób, aby linia je na tej samej linii.

Odpowiedz

23

Oto dość prosty sposób:

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

To działało dobrze. Dzięki! – Benamir

+0

miłe użycie content_for block :) – engineerDave

+0

Hej, to świetna sztuczka z 'content_for'. Bardzo przydatne. – paracycle

1

Zapewnienie wyboru i tekst są wystarczająco małe, aby zmieścić się w jednym rzędzie wewnątrz pojemnika, a następnie ustawić display: inline; lub float:left;

+0

display: inline nie działa i pływa po lewej stronie działa, ale wygląda dziwnie, ponieważ moja forma jest wyśrodkowana. – Benamir

0

Spróbuj użyć wrapper_html tak:

<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

hmm, niestety to wciąż nie działa. – Benamir