我正在尝试将这个rails生成的表单实现为我找到的引导程序表单,并且无法找出正确的语法以使其正常工作。
这是rails 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 :(得分:1)
你走了。你应该真的咨询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 %>
答案 1 :(得分:0)
ERB <%= form_tag %>
,<%= label_tag %>
等是帮助您创建HTML <form>
和<label>
标记(因此是ERB名称)
将Boostrap表单更改为ERB就像复制div和classes / 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 %>