-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only validate/update collection forms that are being modified #465
Comments
Can you give some examples of the incoming |
BTW we're permanently working on a new approach to Reform called |
hey @apotonick, for sure! I'm backing this form by an ActiveRecord model: let's say in this case the model is If I have a params hash like: {
token: '1234',
company_visitors: [
{ company_id: 1, first_name: 'Shirley' },
{ company_id: 51, first_name: 'Bob' },
{ company_id: 501, first_name: 'Carol' },
]
} When I validate and subsequently save I would expect this to:
Today, I've noticed that it will validate and save every item in the collection (in this example, all 100 CompanyVisitors), so I am looking for a way to only process the relevant collection items, as a result of what's passed in to the params hash. Thanks for your help! Excited to hear more about the |
I've tried to essentially make this a collection that is "write-only", by passing Is there a way to initialize it to an empty array, and only add items to the collection based on the work that is done in the populator? That should account for the case I mentioned above, where I only want objects that are referenced in the params to be part of the object graph. |
Any thoughts on how best to move forward with this @apotonick @fran-worley? |
Ok, I see the problem now. I am redesigning Reform/Disposable currently and making it easier to handle those "special" cases manually (because we can't cover all the needs without blowing up the API). The main problem is that Disposable, for your collection will do |
Hi there!
Thanks for writing a great library! I'm using Reform to a manage a collection of nested forms from a parent form. My parent form looks like:
I've noticed that if I have many
company_visitors
, all of them get validated and saved during the process of saving theGlobalVisitor::SaveForm
, even if mycompany_visitors
parameters do not reference any existing objects and mypopulator
returns a new instance.I am trying to find a way to configure my collection, such that it only contains the relevant items based on the incoming parameters. Or a way to exclude the items that are not being updated from being validated/saved. For a parent object that has many collection items, it results in quite a bit of unneeded work, when we know at the time of validation the subset of the collection we need to process. Any advice on how to go about this?
Thanks!
The text was updated successfully, but these errors were encountered: