Ze Ca wrote:
> Colin Law wrote:
>> On 19 April 2010 15:32, Ze Ca <[email protected]> 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.
>> 
>> Colin
> 
> 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 
(generally JavaScript).

In your case the JavaScript would need to know the state capitals by 
state name. In order to push that JavaScript to the client you need to 
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.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to