14
votes

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?

1
Could you paste the HTML output you get from this call? - Tigraine

1 Answers

30
votes

I'm not using the simple_form plugin for Rails, but as the documentation says you should use the :input_html attribute for this.

Do the following:

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