Ze Ca wrote:
Colin Law wrote:
a toy project meant for learning about hidden form fields. I'm mainly
curious what I could do with them.
Anything you put in a hidden form field will be available in the
params array in the controller. That is about it really.
I appreciate the reply, however what I'm trying to figure out is if I
could pass to the controller a specific parameter based on what the user
selects in the form select menu. Basically have some logic in the form
so that if I choose :state => "New York" from the select menu of states,
the hidden field :state_capital => "Albany" will be passed along with
it. I used formtastic to easily generate the hidden fields, but I'm
having trouble with the logic.
What several of the responses are trying to tell you is that what you're
attempting is pointless. If the server-side code can determine the state
capital from the state name then there's no point shoving that
information into a hidden field. Just look it up server-side.
HTML forms, once generated and sent to the client browser, are static.
There is no interactions between form fields on the client-side. In
order to add client-side interaction you need client-side scripting
send it to them from the server-side. Since in either case the
sever-side already knows how to lookup state capitals from state names,
putting that information into a hidden field is pointless.