From 4e9ca82a0f12c6c762e3f3944f0f4abec63ba29e Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 30 Aug 2019 15:42:00 +0300 Subject: [PATCH] `FlexForm`: Fixed some compatibility issues with Form plugin --- CHANGELOG.md | 2 + system/src/Grav/Framework/Flex/FlexForm.php | 51 +++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c6be38c2..ab0094863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ 1. [](#improved) * Improved language support +1. [](#bugfix) + * `FlexForm`: Fixed some compatibility issues with Form plugin # v1.7.0-beta.6 ## 08/29/2019 diff --git a/system/src/Grav/Framework/Flex/FlexForm.php b/system/src/Grav/Framework/Flex/FlexForm.php index fecebd54b..6974341f5 100644 --- a/system/src/Grav/Framework/Flex/FlexForm.php +++ b/system/src/Grav/Framework/Flex/FlexForm.php @@ -17,6 +17,7 @@ use Grav\Framework\Flex\Interfaces\FlexFormInterface; use Grav\Framework\Flex\Interfaces\FlexObjectInterface; use Grav\Framework\Form\Traits\FormTrait; use Grav\Framework\Route\Route; +use RocketTheme\Toolbox\ArrayTraits\NestedArrayAccessWithGetters; use Twig\Error\LoaderError; use Twig\Error\SyntaxError; use Twig\Template; @@ -28,6 +29,10 @@ use Twig\TemplateWrapper; */ class FlexForm implements FlexFormInterface { + use NestedArrayAccessWithGetters { + NestedArrayAccessWithGetters::get as private traitGet; + NestedArrayAccessWithGetters::set as private traitSet; + } use FormTrait { FormTrait::doSerialize as doTraitSerialize; FormTrait::doUnserialize as doTraitUnserialize; @@ -134,6 +139,52 @@ class FlexForm implements FlexFormInterface return $this; } + /** + * @param string $name + * @param mixed $default + * @param string|null $separator + * @return mixed + */ + public function get($name, $default = null, $separator = null) + { + switch (strtolower($name)) { + case 'id': + case 'uniqueid': + case 'name': + case 'noncename': + case 'nonceaction': + case 'action': + case 'data': + case 'files': + case 'errors'; + case 'fields': + case 'blueprint': + case 'page': + $method = 'get' . $name; + return $this->{$method}(); + } + + return $this->traitGet($name, $default, $separator); + } + + /** + * @param string $name + * @param mixed $value + * @param string|null $separator + * @return FlexForm + */ + public function set($name, $value, $separator = null) + { + switch (strtolower($name)) { + case 'id': + case 'uniqueid': + $method = 'set' . $name; + return $this->{$method}(); + } + + return $this->traitSet($name, $value, $separator); + } + /** * @return string */