Monday, August 13, 2012

Re: [Rails] how to do form parameter naming from the form tag?

On 13 August 2012 20:50, Lille <lille.penguini@gmail.com> wrote:
> Hi,
>
> Just like with input tags in a form, where parameter naming can be
> influenced by modifying the tag name attribute...
>
> <input id="person_name" name="person[name]" type="text" value="Henry"/>
>
> ...results in...
>
> {'person' => {'name' => 'Henry'}}
>
> (source: guides.rubyonrails.org/form_helpers.html#basic-structures)
>
> Can I insert attributes into form_tag to customize the parameterization of
> all items inside? For example,
>
> {'whatever_i_want_to_use_as_a_key' => {'person' => {'name' => 'Henry'}}}

Yes it should work. Did you try it?

I would say though that you should use form_for rather than form_tag
if possible. So if the form is displaying data for an object then use
form_for.

If you are a beginner then, if you have not already done so, I suggest
you work right through some tutorials such as railstutorial.org (which
is free to use online), that will give you a good basic knowledge of
rails. Make sure you use a tutorial for rails 3 and install the
correct version of Rails.

Colin

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate