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
Now let's say I want to edit a baz repeater item directly in the page editor as if it were any other page.
When I save the baz item, I also want to ultimately save /some-page/ to which it belongs through the nested relationship to make any changes to that page which would be required based on the changes of the baz item.
I can currently do this with an after save hook that does $baz->getForPage()->getForPage()-getForPage()->save(['noHooks'=>true]);
However, if you think this through much further, I would also want to update boo and lol items as well and even foo and bar
and baz items.
I have currently achieved this by hardcoding a method that drills through the repeater fields and nested repeater fields (let's call them offspring) I've defined of all the repeater items and looping through them and saving each item accordingly.
However, it sure would be nice if that offspring structure could be determined dynamically.
So for example something like this:
$pages->get('/some-page/')->getRepeatersOffspring($options); // $options could have filters to include/exclude fields
Would result in an array or object that looks something like this (with more data ideally):
- foo
- bar
- baz
- boo
- lol
The text was updated successfully, but these errors were encountered:
jlahijani
changed the title
Add ability for a page/template to know it the structure of its repeaters and nested+ repeaters (offspring)
Add ability for a page/template to know the structure of its repeaters and nested+ repeaters (offspring)
Feb 4, 2025
Uh oh!
There was an error while loading. Please reload this page.
I'm taking full advantage of repeater nesting as it is a "belongs-to + has-many" type of relationship common in web application design.
Let's say I have the following (note the indentation which represents nesting):
Now let's say I want to edit a baz repeater item directly in the page editor as if it were any other page.
When I save the baz item, I also want to ultimately save /some-page/ to which it belongs through the nested relationship to make any changes to that page which would be required based on the changes of the baz item.
I can currently do this with an after save hook that does
$baz->getForPage()->getForPage()-getForPage()->save(['noHooks'=>true]);
However, if you think this through much further, I would also want to update boo and lol items as well and even foo and bar
and baz items.
I have currently achieved this by hardcoding a method that drills through the repeater fields and nested repeater fields (let's call them offspring) I've defined of all the repeater items and looping through them and saving each item accordingly.
However, it sure would be nice if that offspring structure could be determined dynamically.
So for example something like this:
Would result in an array or object that looks something like this (with more data ideally):
The text was updated successfully, but these errors were encountered: