Say you want to create a form about a City model, which belongs_to a Country model. You can have fields like: <%= text_field :city, :population %> <%= text_field :country, :official_language %> to make field names city[population] & country[official_language] and posted params { :city => {:population => 123}, :country => {:official_language => ''English''} } You then have to move the country object into the city object if you want to validate and save it as one. What''s the easiest way to make a tag with name city[country][official_language] so that the country object gets put in the city object and you can do automatic associated validation and saving? The correct value also needs to be retrieved to do fill-in. I couldn''t find a permutation that worked using text_field. Can it be done, and if not, can the field_helpers be modified to support this? Otherwise I''ll have to either construct the names and values using the text_tag helper, or do the manual multi-level object manipulation on both get (fill-in) and post. -- We develop, watch us RoR, in numbers too big to ignore.
Mark Reginald James
2005-Aug-26 16:20 UTC
Re: Multi-level objects in form helpers [patch available]
I made a patch to actionpack code that enables use of compound objects in form helpers. See the following rails research-patch ticket: http://dev.rubyonrails.org/ticket/2053 -- We develop, watch us RoR, in numbers too big to ignore.