2017-08-29 1 views
0

Ich versuche, diese Schienen generierte Form in eine Bootstrap-Form, die ich gefunden habe, zu implementieren und kann nicht herausfinden, die richtige Syntax, damit es richtig aussehen/arbeiten.Eingabe von Schienen Erb-Syntax in Bootstrap 4 Formular

ist dies die Schienen erb Syntax

<%= form_tag users_sessions_path do %> 

      <%= label_tag :email %> 
      <%= text_field_tag :email %> 
     <p> 
      <%= label_tag :password %> 
      <%= password_field_tag :password %> 
     </p> 

     <p> 
      <%= submit_tag 'Log In' %> 
     </p> 
<% end %> 

und dies ist die Bootstrap-Form

<form> 
    <div class="form-group"> 
    <label for="exampleInputEmail1">Email address</label> 
    <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Email"> 
    <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small> 
    </div> 
    <div class="form-group"> 
    <label for="exampleInputPassword1">Password</label> 
    <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password"> 
    </div> 
    <div class="form-check"> 
    <label class="form-check-label"> 
     <input type="checkbox" class="form-check-input"> 
     Check me out 
    </label> 
    </div> 
    <button type="submit" class="btn btn-primary">Submit</button> 
</form> 

Antwort

0

Hier gehen Sie. Sie sollten sich wirklich mit RoR api documents beraten.

<%= form_tag users_sessions_path do %> 
    <div class="form-group"> 
    <%= label_tag :email, 'Email address' %> 
    <%= text_field_tag :email, nil, class: 'form-control', id: 'exampleInputEmail1', placeholder: 'Email' %> 
    <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small> 
    </div> 
    <div class="form-group"> 
    <%= label_tag :password %> 
    <%= password_field_tag :password, nil, class: 'form-control', id: 'exampleInputPassword1', placeholder: 'Password' %> 
    </div> 
    <div class="form-check"> 
    <label class="form-check-label"> 
     <%= check_box_tag :remember_me, true, false, class: 'form-check-input' %> 
     Check me out 
    </label> 
    <%= submit_tag 'Submit' %> 
<% end %> 
+0

Vielen Dank für die Hilfe, das hat perfekt funktioniert. –

0

der ERB <%= form_tag %>, <%= label_tag %> usw. sind Helfer die HTML-<form> und <label>-Tags zu erstellen (daher der ERB-Name)

Das Ändern Ihrer Boostrap-Form in ERB ist so einfach wie das Kopieren über die Divs und Klassen/IDs

<%= form_tag users_sessions_path do %> 
    <div class="form-group"> 
    <%= label_tag :email %> 
    <%= text_field_tag :email, class: 'form-control', 
           id: 'exampleInputEmail1', 
           aria-describedby: 'emailHelp', 
           placeholder: 'Email' %> 
    </div> 

<!-- Continue with the rest of your code --> 

<% end %> 
Verwandte Themen