sekru Posted November 10, 2016 Share Posted November 10, 2016 Hello, it ist frustrating: if I remove an item of a repeater with help of the API, all images in my page get lost. I have absolutly no idea, why. $gruppe = (int) $input->get->gruppe; $mitarbeiter = (int) $input->get->mitarbeiter; $m = $pages->get($mitarbeiter); $m->of(false); $delGruppe = $m->gruppenzuordnung->get("gruppe=".$gruppe); $m->gruppenzuordnung->remove($delGruppe); // If I remove this line, no images are lost $m->save(); The lost image is in $m->image. It has nothing to do with the repeater $m->gruppenzuordnung. They remain on the server as file, but not in the database. Has any one an idea? thx, sekru Link to comment Share on other sites More sharing options...
Robin S Posted November 11, 2016 Share Posted November 11, 2016 I'm not sure what's causing your issue, but does it make a difference if you save only the repeater field rather than the whole page? $m->save('gruppenzuordnung'); 1 Link to comment Share on other sites More sharing options...
szabesz Posted November 11, 2016 Share Posted November 11, 2016 9 hours ago, sekru said: if I remove an item of a repeater Which one is the repeater? gruppe? You are trying to remove the repeater form its own item, as far as I can see. $m is a Page object, not a (Repeater)PageArray if I'm correct: $m->gruppenzuordnung->remove($delGruppe); So incidentally it is probably the image this line removes because of a matching key of the image: http://kongondo.github.io/ProcessWireAPIGen/devns/source-class-ProcessWire.WireData.html#333-351 You need to work on the RepeaterPageArray: http://kongondo.github.io/ProcessWireAPIGen/devns/class-ProcessWire.PageArray.html#_remove like this: $delGruppe->remove($m); // or $gruppe->remove($m); // depending on what you want to achieve 1 Link to comment Share on other sites More sharing options...
sekru Posted November 11, 2016 Author Share Posted November 11, 2016 This line helped me: $m->save('gruppenzuordnung'); Tank you, guys! 1 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