Ruby-on-rails – rails simple_form – hidden field – create

form-forhidden-fieldruby-on-railsruby-on-rails-3simple-form

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

Best Answer

try this

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