将 rails erb 语法输入 bootstrap 4 形式
inputing rails erb syntax into bootstrap 4 form
我正在尝试将此 rails 生成的表单实现为我找到的 bootstrap 表单,但无法找出正确的语法来使其 look/work 正确。
这是 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 %>
这是 bootstrap 形式
<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>
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 %>
给你。你真的应该咨询 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 %>
我正在尝试将此 rails 生成的表单实现为我找到的 bootstrap 表单,但无法找出正确的语法来使其 look/work 正确。
这是 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 %>
这是 bootstrap 形式
<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>
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 %>
给你。你真的应该咨询 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 %>