[英]How do I translate an HTML input field to “simple_form”?
我有以下HTML輸入字段:
<input type="text" class="login-field" value="" placeholder="Enter your name" id="login-name" />
<label class="login-field-icon fui-user" for="login-name"></label>
我想將其轉換為我的simple_form
字段,因此它將具有與類,id等相同的屬性。
<%= f.input :email%>
有沒有一種方法可以在simple_form
字段內添加HTML屬性?
<%= simple_form_for @user do |f| %>
<%= f.input :username, label: 'Your username please' %>
<%= f.input :password, hint: 'No special characters.' %>
<%= f.input :email, placeholder: 'user@domain.com' %>
<%= f.input :remember_me, inline_label: 'Yes, remember me' %>
<%= f.button :submit %>
<% end %>
默認情況下,它包含labels
。
同樣,輸入調用中的特定選項將覆蓋默認值:
<%= f.input :username, input_html: { class: 'special' } %>
看看他們的Github頁面,一切都在那里。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.