Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Is :namespace supposed to change field names? #651

Closed
DaveSanders opened this Issue Aug 11, 2011 · 2 comments

Comments

Projects
None yet
2 participants

I have two forms on the same page with (potentially) the same object driving both. (a bill to / same as other address situation) I use :namespace=>billing on the second form and it half works:

`


  • Billing Name*

  • `

    as you see, the input is prefixed with billing in the "id" attribute, but not the "name" attribute. Jquery's serializeArray() looks at the name attribute, so my form params are coming back as params[:property][:name], and since the second form is hidden and filled with blanks, this means my data is blank also.

    Shouldn't :namespace also change the field name attribute? Or do I need to do that manually? Or am I just confused? :)

    Owner

    justinfrench commented Aug 12, 2011

    Hi, namespace was added to address the potential for multiple HTML elements on the page to have the same DOM id, which would cause an invalid document. I don't see any real problem extending this to the name attribute etc, but I think in this case Rails already provides an :as option on form_for. Could you look not that and see if it solves your problem?

    You are completely right. :as works perfectly. Sorry about that, that's two strikes against me on reporting issues now. I'm going to have to think carefully before I use my last wish. :)

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment