So…say you’re in RoR and you want to pass to yourself some specific value to a hidden part of a form? Something that doesn’t totally match a DB entry, in the name?
(This shows you how to specify the starting value, which also applies to other types besides hidden fields, BTW)
<%= hidden_field ‘filter’, “id”, :value => “newvalue” %>
This generates filter[id] = newvalue in the HTML.
What this actually does is allows you to setup an “arbitrary” value to pass into the controller.Â Typically with RoR
<%= hidden_field ‘filter_to_use’, “id” %>
Generates <code>filter_to_use[id] = filter_to_use.id </code> in the HTML (I think). This is of course not useful if filter_to_use is a variable name that is just a variable you want to pass in to the next controller (i.e. it doesn’t exist).Â So you need to use the <code> :value => whatever </code>above.
To use it in the receiving controller:
@filter = Filter.find(params[:filter_to_use][:id]) # retarded
What this does is looks up your parameter. So that’s a little contorted, but works, once you know how to set the value.