简体   繁体   English

如何将HTML输入字段转换为“ simple_form”?

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

I have the following HTML input field: 我有以下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>

I want to translate it into my simple_form field so it will have the same properties like classes, id's etc. 我想将其转换为我的simple_form字段,因此它将具有与类,id等相同的属性。

<%= f.input :email%>

Is there a way to add HTML properties inside the simple_form field? 有没有一种方法可以在simple_form字段内添加HTML属性?

Extracted from simple_form documentation on Github : 摘自Github上的simple_form文档

<%= 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 . 默认情况下,它包含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. 看看他们的Github页面,一切都在那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用AJAX更新simple_form输入字段? - How do I update a simple_form input field using AJAX? 如何使用 CSS 使 simple_form 输入字段更宽? - How to make simple_form input field wider with CSS? 如何更改simple_form输入html标签 - How change simple_form input html tag Ruby on Rails,simple_form - 我想从 html select_tag 字段设置 simple_form 的隐藏字段 - Ruby on Rails, simple_form - I want to set a hidden field of the simple_form from a html select_tag field 当文件存在时,如何在simple_form中更改文件字段的名称? - How do I change the name of the file field in simple_form when a file exists? 如何创建带有可变输入字段的rails simple_form - How do I create a rails simple_form with variable input fields 我如何摆脱将每个输入都包装在simple_form中的div? - How do I get rid of the div that wraps every input in a simple_form? Ruby on Rails-simple_form-如何将输入更改为多项选择下拉菜单? - Ruby on Rails - simple_form - How do I change an input into a multiple choice dropdown? 如何在我的`_navigation.html.erb`中动态生成一个选择菜单,最好是使用simple_form? - How do I dynamically generate a select menu in my `_navigation.html.erb`, preferrably with simple_form? 如何使用simple_form生成输入[type = date]? - How can I generate input[type=date] with simple_form?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM