Skip to content

Commit

Permalink
Merge branch 'release/1.5.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Apr 14, 2021
2 parents 531b2c3 + 8f8e4db commit 2d66932
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Blueprints/src/BlueprintSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ protected function parseFormField($key, array $field, array $params, $prefix = '
// Add all default properties for the field type (field needs to override them).
$type = isset($properties['type']) ? $properties['type'] : '';
if (isset($this->types[$type])) {
$properties = array_merge_recursive($this->types[$type], $properties);
$properties = $this->mergeTypeDefaults($properties, $this->types[$type]);
}

// Merge properties with existing ones.
Expand Down Expand Up @@ -557,6 +557,31 @@ protected function parseFormField($key, array $field, array $params, $prefix = '
}
}

/**
* @param array $properties
* @param array $defaults
* @return array
*/
protected function mergeTypeDefaults(array $properties, array $defaults)
{
foreach ($properties as $key => $value) {
if (is_int($key)) {
// Handle items in a list, but avoid duplicates.
if (!in_array($value, $defaults, true)) {
$defaults[] = $value;
}
} elseif (is_array($value) && isset($defaults[$key]) && is_array($defaults[$key])) {
// Recursively merge array value.
$defaults[$key] = $this->mergeTypeDefaults($value, $defaults[$key]);
} else {
// Replace value.
$defaults[$key] = $value;
}
}

return $defaults;
}

/**
* @param string $key
* @param string $prefix
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v1.5.9
## 04/14/2021

1. [](#bugfix)
* Fixed regression in default field type settings

# v1.5.8
## 04/12/2021

Expand Down

0 comments on commit 2d66932

Please sign in to comment.