rails simple_form - hidden field - create?

Linus Oleander picture Linus Oleander · Mar 20, 2011 · Viewed 122.2k times · Source

How can you have a hidden field with simple form?

The following code:

= simple_form_for @movie do |f|
  = f.hidden :title, "some value"
  = f.button :submit

results in this error:

undefined method `hidden' for #SimpleForm::FormBuilder:0x000001042b7cd0

Answer

fl00r picture fl00r · Mar 20, 2011

try this

= f.input :title, :as => :hidden, :input_html => { :value => "some value" }