I’m trying to add a hidden input with a predetermined “value” in it
<%= f.input :step, :as => :hidden, :input_html => { :value => "3" } %>
In this instance I’m using hidden inputs to determined which form on a page with more than one form is submitted.
This looks to display correctly in the html but submitting the form produces this error
unknown attribute: step
If the field isn’t on your model you have to choices. You can simply use the hidden_field_tag like in the following:
Or you can add a virtual attribute to your model and use the code you’ve shown. Like in the following:
I can’t say which I would use because I don’t what you’re trying to do with the step field.