diff --git a/CHANGELOG.md b/CHANGELOG.md index 7361eefba..9cc02a092 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * Fixed ordering being lost when saving modular `Flex Page` * Fixed `validation: strict` not working in blueprints (see `system.strict_mode.blueprint_compat` setting) [#1273](https://github.com/getgrav/grav/issues/1273) * Fixed `Blueprint::extend()` and `Blueprint::embed()` not initializing dynamic properties + * Regression: Fixed unchecking toggleable having no effect in Flex forms # v1.7.0-rc.6 ## 02/11/2020 diff --git a/system/src/Grav/Common/Data/BlueprintSchema.php b/system/src/Grav/Common/Data/BlueprintSchema.php index b37bbdb1a..de7fb8897 100644 --- a/system/src/Grav/Common/Data/BlueprintSchema.php +++ b/system/src/Grav/Common/Data/BlueprintSchema.php @@ -183,26 +183,7 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface { $results = []; - if ($missingValuesAsNull) { - // First pass is to fill up all the fields with null. - foreach ($rules as $key => $val) { - if ($key && $key !== '*') { - $rule = $this->items[$parent . $key] ?? null; - - if (!$rule || !empty($rule['disabled']) || !empty($rule['validate']['ignore'])) { - continue; - } - - $results[$key] = null; - } - } - } - foreach ($data as $key => $field) { - if (null === $field && !$missingValuesAsNull) { - continue; - } - $val = $rules[$key] ?? $rules['*'] ?? null; $rule = \is_string($val) ? $this->items[$val] : $this->items[$parent . $key] ?? null; @@ -212,6 +193,15 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface continue; } + if (null === $field) { + if ($missingValuesAsNull) { + $results[$key] = null; + } else { + unset($results[$key]); + } + continue; + } + if ($rule && $rule['type'] !== '_parent') { $field = Validation::filter($field, $rule); } elseif (\is_array($field) && \is_array($val)) { diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index 989bddfe0..39469c929 100644 --- a/system/src/Grav/Framework/Flex/FlexObject.php +++ b/system/src/Grav/Framework/Flex/FlexObject.php @@ -120,7 +120,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface $blueprint->validate($elements); - $elements = $blueprint->filter($elements); + $elements = $blueprint->filter($elements, true, true); } $this->filterElements($elements); @@ -547,7 +547,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface // Validate and filter elements and throw an error if any issues were found. $blueprint->validate($test + ['storage_key' => $this->getStorageKey(), 'timestamp' => $this->getTimestamp()]); - $data = $blueprint->filter($data, false, true); + $data = $blueprint->filter($data, true, true); // Finally update the object. foreach ($blueprint->flattenData($data) as $key => $value) {