尝试将 html 标签拉入我的 Rails 简单形式以拉取 id 标签 css 属性

Trying to pull html tag into my Rails simple-form to pull id tags css attributes

快点。我有下面的 html 代码。我正在尝试将其重构为简单的表单代码,以便在我的 rails 应用程序中使用。

<input type="email" class="form-control" id="newsletter" placeholder="Please Enter Your Email">

这是我目前所了解的,但它并没有真正引入 Id 值来查看我想要的结果。

<%= f.input :email, placeholder: "Please Enter Your Email", class: "form-control", id: "newsletter", :input_html => { :type => "email" }, label: false  %>

好吧,就这么简单,我在填写问题后就自己回答了。所以我现在就回答。要为 Rails 简单格式代码拉入 id 标记,您需要以下语法。

<%= f.input :email, placeholder: "Please Enter Your Email", class: "form-control", :input_html => { id: "newsletter", type: "email" }, label: false  %>

所以 :input_html => { id: "newsletter"} 引入了 html id 标签。

我知道很容易。我把这个留在这里,供有需要的人使用,如果他们遇到类似的事情。