mirror of
https://github.com/processwire/processwire.git
synced 2025-08-25 23:56:41 +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) {
|
public function setParent(InputfieldWrapper $parent) {
|
||||||
if($this->parent && $this->parent instanceof InputfieldWrapper && $this->parent !== $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;
|
$this->parent = $parent;
|
||||||
return $this;
|
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.
|
* 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);
|
array_push($wrappers, $inputfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$inputfield->unsetParent();
|
||||||
$wrapper->add($inputfield);
|
$wrapper->add($inputfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user