2017-08-29 39 views
0

我想實現這個軌道生成的形式到我找到的引導形式,並不能找出正確的語法,讓它看起來/工作正確。輸入rails erb語法到引導4形式

這是軌道的erb語法

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

,這是自舉形式

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

回答

0

在這裏,你去。你應該真的諮詢RoR api documents

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

謝謝你的幫助,這完全解決了。 –

0

的ERB <%= form_tag %><%= label_tag %>等是助手來創建HTML <form><label>標籤(因此ERB名稱)

將您的Boostrap表單改爲ERB就像複製div的表單一樣簡單和類/ 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 %>