])
]);
+ $this->form->build();
+
$this->form->getDataHandler()->add(new CustomFormFieldDataProcessor('isDisabledToString', function(IFormDocument $document, array $parameters) {
unset($parameters['data']['isDisabled']);
*/
protected $enctype = '';
+ /**
+ * is `true` if form document has already been built and is `false` otherwise
+ * @var bool
+ */
+ protected $isBuilt = false;
+
/**
* @inheritDoc
*/
return $this;
}
+ /**
+ * @inheritDoc
+ */
+ public function build() {
+ if ($this->isBuilt) {
+ throw new \BadMethodCallException("Form document has already been built.");
+ }
+
+ /** @var IFormNode $node */
+ foreach ($this->getIterator() as $node) {
+ $node->populate();
+ }
+
+ $this->isBuilt = true;
+
+ return $this;
+ }
+
/**
* @inheritDoc
*/
*/
public function action($action);
+ /**
+ * Is called once after all nodes have been added to this document.
+ *
+ * This method is intended to trigger `TODO` to allow nodes to perform actions that
+ * require the whole document having finished constructing itself and every parent-
+ * -child relationship being established.
+ *
+ * @return static this document
+ *
+ * @throws \BadMethodCallException if this document has already been built
+ */
+ public function build();
+
/**
* Returns the `action` property of the HTML `form` element.
*
*/
public function id($id);
+ /**
+ * Is called once after all nodes have been added to the document this node belongs to.
+ *
+ * This method enables this node to perform actions that require the whole document having
+ * finished constructing itself and every parent-child relationship being established.
+ *
+ * @return static this node
+ *
+ * @throws \BadMethodCallException if this node has already been populated
+ */
+ public function populate();
+
/**
* Removes the given CSS class and returns this node.
*
/**
* Checks if the given attribute name class a string and a valid attribute name.
- *
+ *
* @param mixed $name checked argument name
- *
+ *
* @throws \InvalidArgumentException if the given attribute name is no string or otherwise invalid
*/
public static function validateAttribute($name);
/**
* Checks if the given parameter class a string and a valid node class.
- *
+ *
* @param mixed $class checked class
- *
+ *
* @throws \InvalidArgumentException if the given id is no string or otherwise invalid
*/
public static function validateClass($class);
*/
protected $__id;
+ /**
+ * is `true` if node has already been populated and is `false` otherwise
+ * @var bool
+ */
+ protected $isPopulated = false;
+
/**
* list of attribute names that may not be set using `attribute()`
* @var string[]
return $this;
}
+ /**
+ * Is called once after all nodes have been added to the document this node belongs to.
+ *
+ * This method enables this node to perform actions that require the whole document having
+ * finished constructing itself and every parent-child relationship being established.
+ *
+ * @return static this node
+ *
+ * @throws \BadMethodCallException if this node has already been populated
+ */
+ public function populate() {
+ if ($this->isPopulated) {
+ throw new \BadMethodCallException('Node has already been populated');
+ }
+
+ $this->isPopulated = true;
+
+ return $this;
+ }
+
+
/**
* Removes the given CSS class and returns this node.
*