diff --git a/CHANGELOG.md b/CHANGELOG.md index 51205cd76..86e137c8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 1. [](#new) * Added `authorize-*@:` support for Flex blueprints, e.g. `authorize-disabled@: not delete` disables the field if user does not have access to delete object + * Added support for `flex-ignore@` to hide all the nested fields in the blueprint # v1.7.35 ## 08/04/2022 diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php index ef6aef50d..906fd7917 100644 --- a/system/src/Grav/Common/Data/Blueprint.php +++ b/system/src/Grav/Common/Data/Blueprint.php @@ -515,7 +515,7 @@ protected function dynamicSecurity(array &$field, $property, array &$call) $success = $this->resolveActions($user, $actions); } if (!$success) { - $this->addPropertyRecursive($field, 'validate', ['ignore' => true]); + static::addPropertyRecursive($field, 'validate', ['ignore' => true]); } } @@ -566,7 +566,7 @@ protected function dynamicScope(array &$field, $property, array &$call) } if ($matches) { - $this->addPropertyRecursive($field, 'validate', ['ignore' => true]); + static::addPropertyRecursive($field, 'validate', ['ignore' => true]); return; } } @@ -577,7 +577,7 @@ protected function dynamicScope(array &$field, $property, array &$call) * @param mixed $value * @return void */ - protected function addPropertyRecursive(array &$field, $property, $value) + public static function addPropertyRecursive(array &$field, $property, $value) { if (is_array($value) && isset($field[$property]) && is_array($field[$property])) { $field[$property] = array_merge_recursive($field[$property], $value); @@ -587,7 +587,7 @@ protected function addPropertyRecursive(array &$field, $property, $value) if (!empty($field['fields'])) { foreach ($field['fields'] as $key => &$child) { - $this->addPropertyRecursive($child, $property, $value); + static::addPropertyRecursive($child, $property, $value); } } } diff --git a/system/src/Grav/Framework/Flex/FlexDirectory.php b/system/src/Grav/Framework/Flex/FlexDirectory.php index 5368ebce0..7197284e0 100644 --- a/system/src/Grav/Framework/Flex/FlexDirectory.php +++ b/system/src/Grav/Framework/Flex/FlexDirectory.php @@ -920,7 +920,13 @@ protected function dynamicFlexField(array &$field, $property, array $call): void if (is_array($value) && isset($field[$property]) && is_array($field[$property])) { $value = $this->mergeArrays($field[$property], $value); } - $field[$property] = $not ? !$value : $value; + $value = $not ? !$value : $value; + + if ($property === 'ignore' && $value) { + Blueprint::addPropertyRecursive($field, 'validate', ['ignore' => true]); + } else { + $field[$property] = $value; + } } }