-
Notifications
You must be signed in to change notification settings - Fork 46
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
ContainsMany does not fire ref model hook when set or save #881
Comments
in #999 I have fixed traversing issue with ContainsOne/Many ContainsOne/Many model ( In the example, I do not see such manual save called - @ibelar when you reload |
Getting the Accounts data correctly was not the issue here. What I meant was that when Account model hook are used, like
It might not have been implement before as well, so I am not sure if this is a bug or more of a feature request. I am also not fully aware of the latest change in Data so its perhaps even fixed. |
see #1004 test
however, I still do not undestand this issue ticket completely - what you want to test data/tests/ContainsManyTest.php Line 349 in abd00b3
but there is a delete bug - when root model is deleted, delete hooks for the inner models are not fixed (I will fix this shortly) |
Not sure what more you need. This is relatively simple. Like I said before, It might be the intended way that Account hook are not fired. If this is the case then there is no issue. |
@ibelar In #1004 I have put a test case together and I want you to edit it to replicate the issue you describe. Please fork the PR, edit it and push the failing test case directly to the PR branch or post it here. Please also see #881 (comment). In atk4/data, you can not use |
From what I know, you can set containsMany model via Model::set() parent model. Setting Account field the way below work fine:
Setting field value within a Form model after submit is also done this way when Form use a Multiline control that is reference to a containsMany field. |
@ibelar It works as the internal Currently, the data are completely unchecked when Ah, in #881 (comment) you described you want Also, can you post a link (/w line) to a code/Multiline where the |
Yes!
Below is a simple setup. Form will add a Multiline control for the 'Account' field. The field get set in Control class (see: https://github.com/atk4/ui/blob/5af98f3ca91046de0318bab8f9435db664e837b3/src/Form/Control.php#L97) and the value is an array return by Multiline.
|
also please see atk4/ui#1797 - I tested MultiLine with
so is this issue with hooks really present in Multiline (or elsewhere in atk4/ui)? also, the MultiLine control does not have any Behat test, would you be so kind and add a Behat test for the basic operations? |
Please note that the issue is not in Multiline. if this code below is firing hook in Account model then it will be working in Multiline.
Beside, Multiline set up in demo is not related to this. Multiline can be used in three different ways:
|
Any direct data modifications is not wanted, like updating DB with SQL directly instead of via Model with proper normalization incl. hooks and other business logic. |
Consider code below:
When changing Accounts reference value, then the Account model hook should be fire. Actually id does not.
Ex:
Then, when setting Account or saving Client, the Account model hook should be fired.
The text was updated successfully, but these errors were encountered: