简体   繁体   中英

How do I translate an HTML input field to “simple_form”?

I have the following HTML input field:

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

I want to translate it into my simple_form field so it will have the same properties like classes, id's etc.

<%= f.input :email%>

Is there a way to add HTML properties inside the simple_form field?

Extracted from simple_form documentation on Github :

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

By default it contains labels .

Also, specific options in input call will overwrite the defaults:

 <%= f.input :username, input_html: { class: 'special' } %>

Have a look at their Github page, everything is there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM