gebeer Posted May 10, 2017 Share Posted May 10, 2017 Hello, I have a repeater field with an image (single) field. I would like to attach a hook when the repeater item has changed. But the change event is not triggered, when uploading an image. When removing an image the repeater item shows as changed. Here's my hook $this->addHookAfter('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments[0]; if($page->template != 'member') return; $historyItems = $page->get('history'); // repeater field foreach ($historyItems as $key => $item) { if($item->isChanged()) bardump('CHANGED'); } }); This looks like a bug to me. Can anybody reproduce this? PW 3.0.61 Link to comment Share on other sites More sharing options...
Robin S Posted May 10, 2017 Share Posted May 10, 2017 You could try hooking after saveReady for the repeater pages themselves: $this->addHookAfter('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments[0]; if($page->template != 'repeater_history') return; if($page->isChanged()) bardump('CHANGED'); }); Link to comment Share on other sites More sharing options...
gebeer Posted May 11, 2017 Author Share Posted May 11, 2017 @Robin S That is pretty neat! And I will use it to execute my logic. For testing, I am using this now: $this->addHookAfter('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments[0]; if($page->template == 'repeater_history') bardump($page->isChanged()); // this line is not executed when adding an image and then saving the page }); BUT it still doesn't trigger page change when I upload an image to the repeater item and then save the page. Deleting the image does trigger page as changed. So same behavior as with my above hook code. Looks like a bug to me. On a normal page (non repeater) the change event is triggered when uploading an image and then saving the page. Only for repeater pages this does not happen. Link to comment Share on other sites More sharing options...
Robin S Posted May 11, 2017 Share Posted May 11, 2017 7 minutes ago, gebeer said: BUT it still doesn't trigger page change when I upload an image to the repeater item and then save the page. Hmm, I just tested this and it works for me. That is, $page->isChanged() returns true after uploading an image to a repeater item and saving the containing page. And I checked on an existing repeater item as isChanged() is always true for new pages. So weird that it isn't working for you. Link to comment Share on other sites More sharing options...
gebeer Posted May 11, 2017 Author Share Posted May 11, 2017 @Robin S thanks for checking. I have quite a few other hooks going on that might interfere. I thought I had checked on them already. But will do another thorough check and get back here. Link to comment Share on other sites More sharing options...
NorbertH Posted October 10, 2018 Share Posted October 10, 2018 (edited) Having the same issue whith FieldtypeSecureFile . It simply does not Trigger isChanged after i override an image (only 1 document allowede in that field) Edited October 10, 2018 by NorbertH Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now