// re-build form after having created a new object
if ($this->formAction === 'create') {
+ $this->form->cleanup();
+
$this->buildForm();
}
class FormDocument implements IFormDocument {
use TFormNode;
use TFormParentNode {
+ TFormParentNode::cleanup insteadof TFormNode;
readValues as protected defaultReadValues;
}
*/
protected $isBuilt = false;
+ /**
+ * Cleans up the form document before the form document object is destroyed.
+ */
+ public function __destruct() {
+ $this->cleanup();
+ }
+
/**
* @inheritDoc
*/
*/
public function available($available = true);
+ /**
+ * Cleans up after the whole form is not used anymore.
+ * This method has to support being called multiple times.
+ *
+ * This form should not clean up input fields.
+ *
+ * @return static this node
+ */
+ public function cleanup();
+
/**
* Returns `true` if all of the node's dependencies are met and returns `false` otherwise.
*
return true;
}
+ /**
+ * Cleans up after the whole form is not used anymore.
+ * This method has to support being called multiple times.
+ *
+ * This form should not clean up input fields.
+ *
+ * @return static this node
+ */
+ public function cleanup() {
+ return $this;
+ }
+
/**
* Returns the value of the additional attribute of this node with the given name.
*
return $this->__children;
}
+ /**
+ * Cleans up after the whole form is not used anymore.
+ * This method has to support being called multiple times.
+ *
+ * This form should not clean up input fields.
+ *
+ * @return static this node
+ */
+ public function cleanup() {
+ foreach ($this as $child) {
+ $child->cleanup();
+ }
+
+ return $this;
+ }
+
/**
* Returns the number of direct children of this node.
*
use TFormChildNode;
use TFormElement;
use TFormParentNode {
+ TFormParentNode::cleanup insteadof TFormElement;
validateChild as protected defaultValidateChild;
}