You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful to be able to build forms for nested attributes, and using the posted array to update the model and its associated models all at once.
For example, consider an Invoice model that has many Items. The form would send back something like
invoice[id] = 42
invoice[description] = Lorem ipsum dolor
invoice[paid] = 1
invoice[items_attributes][0][description] = First item
invoice[items_attributes][0][price] = 100
invoice[items_attributes][1][description] = Second item
invoice[items_attributes][1][price] = 250
and so on. Then, in Rails, you'd do something like
def update
invoice = Invoice.find(params[:id]) # the id comes from the URL, not from the form
invoice.update_attributes(params[:invoice]) # and this is the array that comes from the form
end
and the ActiveRecord::Base component (educated guess) takes care of updating the model's attributes and any relevant associated object.
The text was updated successfully, but these errors were encountered:
Actually i am currently working on this, in a seperate class layer above phpactiverecord and a function called from_post(). It's already semi functional, if my boss allows it, i'll modify it to fit this description and submit a pull request.
Follow up from https://github.com/kla/php-activerecord/issues/issue/111, see also http://www.phpactiverecord.org/boards/1/topics/309
It would be useful to be able to build forms for nested attributes, and using the posted array to update the model and its associated models all at once.
For example, consider an Invoice model that has many Items. The form would send back something like
and so on. Then, in Rails, you'd do something like
and the ActiveRecord::Base component (educated guess) takes care of updating the model's attributes and any relevant associated object.
The text was updated successfully, but these errors were encountered: