1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-25 07:41:30 +02:00

Fix issue processwire/processwire-issues#716 where $page traversal methods like next() and prev() were not working on RepeaterPage items

This commit is contained in:
Ryan Cramer
2018-10-05 09:48:20 -04:00
parent 5fddd95b43
commit 8e22bee1b5
4 changed files with 80 additions and 14 deletions

View File

@@ -805,7 +805,7 @@ class FieldtypeRepeater extends Fieldtype implements ConfigurableModule {
*
* @param Page $page
* @param Field $field
* @param RepeaterPageArray$value
* @param RepeaterPageArray $value
* @param array $options
* - `minimal` (bool): Export a minimal array of just fields and values indexed by repeater page name (default=false)
* @return array

View File

@@ -5,7 +5,7 @@
*
* Special PageArray for use by repeaters that includes a getNewItem() method
*
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
* ProcessWire 3.x, Copyright 2018 by Ryan Cramer
* https://processwire.com
*
*/
@@ -103,6 +103,32 @@ class RepeaterPageArray extends PageArray {
$newArray = $this->wire(new $class($this->parent, $this->field));
return $newArray;
}
/**
* Track an item added
*
* @param Wire|mixed $item
* @param int|string $key
*
*/
protected function trackAdd($item, $key) {
/** @var RepeaterPage $item */
$item->traversalPages($this);
parent::trackAdd($item, $key);
}
/**
* Track an item removed
*
* @param Wire|mixed $item
* @param int|string $key
*
*/
protected function trackRemove($item, $key) {
/** @var RepeaterPage $item */
if($item->traversalPages() === $this) $item->traversalPages(false);
parent::trackRemove($item, $key);
}
}