Jump to content

Delete Repeater Item


Rodwyn
 Share

Recommended Posts

Hello, I have problems with repeaters. I tried to delete or modify an item from a repeater. But when the page reloads, it appears again. I was also trying to add a new article having the same result. 

Can anyone help me? 

Please 

Link to comment
Share on other sites

Hi Rodwyn,

Welcome to PW forum :) Hopefully the example below help you out:

Deleting
$page->of(false);
$itemToRemove = $page->Body_Repeater->eq(0);
$page->Body_Repeater->remove($itemToRemove);
$page->save();
Editing
$itemToEdit = $page->Body_Repeater->eq(0);
$itemToEdit->of(false);
$itemToEdit->body = "My new content";
$itemToEdit->save();

Things you need to remember with Repeater is that Repeater Item is an actual page in processwire but being hidden in the tree and obviously Repeater field is an array of pages (wirearray). For documentation please refer to this page: https://processwire.com/api/arrays/

Hope this helps :)

  • Like 4
Link to comment
Share on other sites

Thanks peterfoeng.
 
Maybe my problem is in the CMS. 
 
Attached a couple of pictures that illustrate my problem. 
 
borrar_1.png
 
 
borrar_2.png
 
I have a repeater called 'Persona', contains two photographs and two text fields. 
I try to delete the item Persona # 98, I click the trash button and then click the Save button. 
When charge the page, this appears again 
 
What I can do?
Link to comment
Share on other sites

He uses 2.3.0

Wow - I am not very observant today am I :)

I think it likely is the issue:

https://processwire.com/talk/topic/4651-cant-delete-or-modify-repeater-item/

There is another post where Nico suggests upgrading to 2.4 and I think that fixes the issue for the OP, but I can't find it right now. Regardless, you should really be running 2.4 - lots of amazing new things :)

  • Like 3
Link to comment
Share on other sites

Does it show this every time or only once or only sometimes?

"2006 MySQL Server has gone away" can have different reasons. As it states there, it is a "General Error", not a specific. One reason can be that the MySQL server is very busy (shared host?) and you run into a timeout.

Another reason could be that a previously used connection was lost and it couldn't be re-established. This was the behave with the PDO-class in the past, but this was fixed in early march this year. Which PW version have you installed now? If you use 2.4.0 (stable) you have this bug. Then you should go to the dev-branch and get the WireDatabasePDO.php file and copy this over your existing file from 2.4.0: wire/core/WireDatabasePDO.php

If you have installed the latest dev branch allready, it has another reason. :(

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...