14

I am using simple form in my Rails application, i tried to set value and class to a specific input field just like below

<%= f.input :email, :required => true, :autofocus => true, :value => "Email", :class => "myclass" %>

Html output :

enter image description here

but i could not able to see value and class set in the actual html form.

What am i doing wrong?

4

1 回答 1

30

我没有为 Rails 使用simple_form插件,但正如文档所说,您应该为此使用该:input_html属性。

请执行下列操作:

<%= f.input :email, required: true, autofocus: true, input_html: { :value => "Email", class: "myclass" } %>
于 2012-07-04T13:27:26.983 回答