mirror of
https://github.com/processwire/processwire.git
synced 2025-08-24 15:23:11 +02:00
Fix issue processwire/processwire-issues#653 Inputfield parent issue causing out of memory errors when two buttons lacking name attributes
This commit is contained in:
@@ -493,12 +493,31 @@ abstract class Inputfield extends WireData implements Module {
|
||||
*/
|
||||
public function setParent(InputfieldWrapper $parent) {
|
||||
if($this->parent && $this->parent instanceof InputfieldWrapper && $this->parent !== $parent) {
|
||||
$this->parent->remove($this);
|
||||
$oldRootParent = $this->getRootParent();
|
||||
if(!$oldRootParent) $oldRootParent = $this->parent;
|
||||
$newRootParent = $parent->getRootParent();
|
||||
if(!$newRootParent) $newRootParent = $parent;
|
||||
if($oldRootParent === $newRootParent) {
|
||||
// if field staying in the same form, remove from previous parent
|
||||
$this->parent->remove($this);
|
||||
}
|
||||
}
|
||||
$this->parent = $parent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset any previously set parent
|
||||
*
|
||||
* #pw-internal
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function unsetParent() {
|
||||
$this->parent = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this Inputfield’s parent InputfieldWrapper, or NULL if it doesn’t have one.
|
||||
*
|
||||
|
@@ -416,6 +416,7 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre
|
||||
array_push($wrappers, $inputfield);
|
||||
}
|
||||
|
||||
$inputfield->unsetParent();
|
||||
$wrapper->add($inputfield);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user