This might be a really basic question but how do I create default values in forms?
I’m trying to put the <%= params[:id] %> of the page in as a default hidden value in this form.
`<% form_for(@revision) do |f| %>
<%= f.label :background_title %><br />
<%= f.text_field :background_title %><%= params[:id] %>
<%= f.label :title %><br />
<%= f.text_field :title %>
<%= f.submit 'Create' %>
<% end %>`
Thanks.
The form is linked to the object you pass to
form_for, so set the value on the object before you start the form. For example, in the controller:then in the form:
However, I hope this is an example and you’re not actually setting the ID (primary key) of an object based on a URL parameter…