From dab28c5847ca637a248792ba555d94e6c9d84685 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 24 Feb 2019 14:31:08 +0100 Subject: [PATCH] Add loadValuesFromObject support for form containers See #2509 --- .../form/builder/FormDocument.class.php | 26 ++++++++++++------- .../builder/container/FormContainer.class.php | 10 +++++++ .../container/IFormContainer.class.php | 15 ++++++++++- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php b/wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php index 7dc0ebf344..005e2e5983 100644 --- a/wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php @@ -1,6 +1,7 @@ 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); } } } diff --git a/wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php index 075c458bb8..ae9d6d2283 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php @@ -1,5 +1,6 @@