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''}}} Thx, Lille -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/b8-V7wRzu_kJ. For more options, visit https://groups.google.com/groups/opt_out.
You can use the "as" option on your form_for tag: form_for(@person) will generate inputs like "person[name]" form_for(@person, :as => "something[person]") will generate an input like "something[session][email]" -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/sjyTBLr04kUJ. For more options, visit https://groups.google.com/groups/opt_out.
Sorry, should have been "something[person][name]" instead of "something[session][email]" -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/9CdjxUpV5OsJ. For more options, visit https://groups.google.com/groups/opt_out.
On 13 August 2012 20:50, Lille <lille.penguini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
> > 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. >There was no especially good reason to try for this, except I happened to have a form that used form_tag and with no instance variable available for use with form_for. Anyway, let me close this issue, noting that my conclusion is that there is no way to get parameter naming with form_tag like from form_for. Lille -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/UhT85yoWYSEJ. For more options, visit https://groups.google.com/groups/opt_out.
On 13 August 2012 22:37, Lille <lille.penguini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:>> 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. > > > There was no especially good reason to try for this, except I happened to > have a form that used form_tag and with no instance variable available for > use with form_for. > > Anyway, let me close this issue, noting that my conclusion is that there is > no way to get parameter naming with form_tag like from form_for.As I said, it should work with form_tag and form_for. What makes you think that it does not? By the way, there is no need to send a copy of the email directly to me, just send it to the list. 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.