Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting class and value in simple form (Rails)

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?

like image 386
balanv Avatar asked Jul 04 '12 13:07

balanv


1 Answers

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" } %>
like image 90
KARASZI István Avatar answered Nov 09 '22 06:11

KARASZI István