Regression: Fixed unchecking toggleable having no effect in Flex forms

This commit is contained in:
Matias Griese
2020-03-02 21:02:44 +02:00
parent e41072c448
commit d089a1d9c8
3 changed files with 12 additions and 21 deletions

View File

@@ -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

View File

@@ -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)) {

View File

@@ -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) {