Jump to content
manlio

Problem with a repeater field after API data insert

Recommended Posts

Hello! 

I have this problem and I don't know how to fix it.

In the user template, I have inserted a repeater field (called user_payment). This repeater is populated from API after a payment confirmation.

My initial code was wrong and only in a second time I have fixed it adding the last two rows

$mypay = $user->user_payment->getNew();
$mypay->text = $mytext;
$mypay->of(false);
$mypay->save();


//** Added later
$user->user_payment->add($mypay);
$user->save();

Some payments was stored in the wrong way and now I am able to see the data when I edit a user in the PW admin backend, but I can't search them in lister pro or in an API search.

I can fix the problem if I edit the user and save the page from the backend, but I wanna know if there is a way to automatically fix all the data.

Thank you for any suggestion!

Ciao

 

Share this post


Link to post
Share on other sites

This might work:

foreach($users as $u) {
	$u->of(false);
	$u->save('user_payment');
}

 

  • Like 1

Share this post


Link to post
Share on other sites

In the meantime I have manually fixed all the compromised records using the admin and I cannot test it, but thank you very much Robin for taking time to provide this solution.

Really helpful for any additional repeater problem 🙂

Have a nice day.

  • Like 1

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...