Update Composer packages
This commit is contained in:
parent
67c3d8b307
commit
83cb211fe6
219 changed files with 6487 additions and 4444 deletions
|
@ -62,7 +62,10 @@ class Field extends Component
|
|||
public function __construct(string $type, array $attrs = [], ?Fields $formFields = null)
|
||||
{
|
||||
if (isset(static::$types[$type]) === false) {
|
||||
throw new InvalidArgumentException('The field type "' . $type . '" does not exist');
|
||||
throw new InvalidArgumentException([
|
||||
'key' => 'field.type.missing',
|
||||
'data' => ['name' => $attrs['name'] ?? '-', 'type' => $type]
|
||||
]);
|
||||
}
|
||||
|
||||
if (isset($attrs['model']) === false) {
|
||||
|
|
|
@ -202,6 +202,18 @@ class BlocksField extends FieldClass
|
|||
return $this->valueToJson($blocks, $this->pretty());
|
||||
}
|
||||
|
||||
protected function setDefault($default = null)
|
||||
{
|
||||
// set id for blocks if not exists
|
||||
if (is_array($default) === true) {
|
||||
array_walk($default, function (&$block) {
|
||||
$block['id'] ??= Str::uuid();
|
||||
});
|
||||
}
|
||||
|
||||
parent::setDefault($default);
|
||||
}
|
||||
|
||||
protected function setFieldsets($fieldsets, $model)
|
||||
{
|
||||
if (is_string($fieldsets) === true) {
|
||||
|
|
|
@ -115,6 +115,32 @@ class LayoutField extends BlocksField
|
|||
return $routes;
|
||||
}
|
||||
|
||||
protected function setDefault($default = null)
|
||||
{
|
||||
// set id for layouts, columns and blocks within layout if not exists
|
||||
if (is_array($default) === true) {
|
||||
array_walk($default, function (&$layout) {
|
||||
$layout['id'] ??= Str::uuid();
|
||||
|
||||
// set columns id within layout
|
||||
if (isset($layout['columns']) === true) {
|
||||
array_walk($layout['columns'], function (&$column) {
|
||||
$column['id'] ??= Str::uuid();
|
||||
|
||||
// set blocks id within column
|
||||
if (isset($column['blocks']) === true) {
|
||||
array_walk($column['blocks'], function (&$block) {
|
||||
$block['id'] ??= Str::uuid();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
parent::setDefault($default);
|
||||
}
|
||||
|
||||
protected function setLayouts(array $layouts = [])
|
||||
{
|
||||
$this->layouts = array_map(
|
||||
|
|
|
@ -838,11 +838,13 @@ abstract class FieldClass
|
|||
*/
|
||||
protected function valueToJson(array $value = null, bool $pretty = false): string
|
||||
{
|
||||
$constants = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
|
||||
|
||||
if ($pretty === true) {
|
||||
return json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
$constants |= JSON_PRETTY_PRINT;
|
||||
}
|
||||
|
||||
return json_encode($value);
|
||||
return json_encode($value, $constants);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -324,9 +324,7 @@ class Form
|
|||
return $fields;
|
||||
}
|
||||
|
||||
if ($language === null) {
|
||||
$language = $kirby->language()->code();
|
||||
}
|
||||
$language ??= $kirby->language()->code();
|
||||
|
||||
if ($language !== $kirby->defaultLanguage()->code()) {
|
||||
foreach ($fields as $fieldName => $fieldProps) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue