<?php
namespace wcf\system\form\builder;
use wcf\data\IStorableObject;
+use wcf\system\form\builder\container\IFormContainer;
use wcf\system\form\builder\data\FormDataHandler;
use wcf\system\form\builder\data\IFormDataHandler;
use wcf\system\form\builder\field\data\processor\DefaultFormFieldDataProcessor;
/** @var IFormNode $node */
foreach ($this->getIterator() as $node) {
- if ($node instanceof IFormField && $node->isAvailable()) {
- if ($node->getObjectProperty() !== $node->getId()) {
- try {
- $node->loadValueFromObject($object);
+ if ($node->isAvailable()) {
+ if ($node instanceof IFormField) {
+ if ($node->getObjectProperty() !== $node->getId()) {
+ try {
+ $node->loadValueFromObject($object);
+ }
+ catch (\InvalidArgumentException $e) {
+ // if an object property is explicitly set,
+ // ignore invalid values as this might not be
+ // the appropriate field
+ }
}
- catch (\InvalidArgumentException $e) {
- // if an object property is explicitly set,
- // ignore invalid values as this might not be
- // the appropriate field
+ else {
+ $node->loadValueFromObject($object);
}
}
- else {
- $node->loadValueFromObject($object);
+ else if ($node instanceof IFormContainer) {
+ $node->loadValuesFromObject($object);
}
}
}
<?php
namespace wcf\system\form\builder\container;
+use wcf\data\IStorableObject;
use wcf\system\form\builder\IFormChildNode;
use wcf\system\form\builder\IFormDocument;
use wcf\system\form\builder\TFormChildNode;
]), true);
}
+ /**
+ * @inheritDoc
+ */
+ public function loadValuesFromObject(IStorableObject $object) {
+ // does nothing
+
+ return $this;
+ }
+
/**
* @inheritDoc
*/
<?php
namespace wcf\system\form\builder\container;
+use wcf\data\IStorableObject;
use wcf\system\form\builder\IFormChildNode;
use wcf\system\form\builder\IFormElement;
use wcf\system\form\builder\IFormParentNode;
* @package WoltLabSuite\Core\System\Form\Builder\Container
* @since 5.2
*/
-interface IFormContainer extends IFormChildNode, IFormElement, IFormParentNode {}
+interface IFormContainer extends IFormChildNode, IFormElement, IFormParentNode {
+ /**
+ * This method is called by `IFormDocument::loadValuesFromObject()` to inform the container
+ * that object data is loaded.
+ *
+ * This method is *not* intended to generally call `IFormField::loadValueFromObject()` on
+ * its form field children as these methods are already called by `IFormDocument::loadValuesFromObject()`.
+ *
+ * @param IStorableObject $object object used to load field values
+ * @return static this container
+ */
+ public function loadValuesFromObject(IStorableObject $object);
+}