ruby-on-railsruby-on-rails-3form-forhidden-fieldsimple-form

rails simple_form - hidden field - create?


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

Solution

  • try this

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