Jump to content

Duplicate repeater sort order after save


Mackski
 Share

Recommended Posts

I have a strange problem with repeaters, the markup for sort order is rendered correctly, as is the repeater list and markup:

eg:

<input id="sort_repeater73338" class="InputfieldRepeaterSort" name="sort_repeater73338" value="0" type="hidden">
<input id="sort_repeater73322" class="InputfieldRepeaterSort" name="sort_repeater73322" value="1" type="hidden">

After saving, there is no change in the sort order in the DB.

Every repeater with the same parent has the same sort order, no matter what. This happens at the time of created via the API, I am explicitly setting the sort order here:
 

$rep = $p->draw_nomination_repeater->getNew();
$rep->page_link = $array['id'];
$rep->sort = $x++;
$p->draw_nomination_repeater->add($rep);
$p->of(false);
$p->save();

 

snip_20180907064927-CDC2.png

snip_20180907064927-CDC1.png

 

Could the sort change not be detected when creating multiple repeaters via the API?

if($page->isChanged('sort')) {
  // $this->message("Sort changed for field {$this->field} page {$page->id}", Notice::debug); 
  $sortChanged = true;
}

 

Link to comment
Share on other sites

First thing would be to use Tracy to check what the value of $x is when you create your repeater pages. Your post doesn't show where this variable is declared - maybe it is being reset within your loop or isn't incrementing as expected for some other 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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...