Upgrade to 3.7.0
This commit is contained in:
0
kirby/src/Form/Field.php
Normal file → Executable file
0
kirby/src/Form/Field.php
Normal file → Executable file
10
kirby/src/Form/Field/BlocksField.php
Normal file → Executable file
10
kirby/src/Form/Field/BlocksField.php
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Kirby\Form\Field;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Block;
|
||||
use Kirby\Cms\Blocks as BlocksCollection;
|
||||
use Kirby\Cms\Fieldsets;
|
||||
@@ -12,6 +13,7 @@ use Kirby\Form\Form;
|
||||
use Kirby\Form\Mixin\EmptyState;
|
||||
use Kirby\Form\Mixin\Max;
|
||||
use Kirby\Form\Mixin\Min;
|
||||
use Kirby\Toolkit\Str;
|
||||
use Throwable;
|
||||
|
||||
class BlocksField extends FieldClass
|
||||
@@ -28,7 +30,7 @@ class BlocksField extends FieldClass
|
||||
|
||||
public function __construct(array $params = [])
|
||||
{
|
||||
$this->setFieldsets($params['fieldsets'] ?? null, $params['model'] ?? site());
|
||||
$this->setFieldsets($params['fieldsets'] ?? null, $params['model'] ?? App::instance()->site());
|
||||
|
||||
parent::__construct($params);
|
||||
|
||||
@@ -142,13 +144,15 @@ class BlocksField extends FieldClass
|
||||
return [
|
||||
[
|
||||
'pattern' => 'uuid',
|
||||
'action' => fn () => ['uuid' => uuid()]
|
||||
'action' => fn () => ['uuid' => Str::uuid()]
|
||||
],
|
||||
[
|
||||
'pattern' => 'paste',
|
||||
'method' => 'POST',
|
||||
'action' => function () use ($field) {
|
||||
$value = BlocksCollection::parse(get('html'));
|
||||
$request = App::instance()->request();
|
||||
|
||||
$value = BlocksCollection::parse($request->get('html'));
|
||||
$blocks = BlocksCollection::factory($value);
|
||||
return $field->blocksToValues($blocks->toArray());
|
||||
}
|
||||
|
9
kirby/src/Form/Field/LayoutField.php
Normal file → Executable file
9
kirby/src/Form/Field/LayoutField.php
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Kirby\Form\Field;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Blueprint;
|
||||
use Kirby\Cms\Fieldset;
|
||||
use Kirby\Cms\Layout;
|
||||
@@ -18,7 +19,7 @@ class LayoutField extends BlocksField
|
||||
|
||||
public function __construct(array $params)
|
||||
{
|
||||
$this->setModel($params['model'] ?? site());
|
||||
$this->setModel($params['model'] ?? App::instance()->site());
|
||||
$this->setLayouts($params['layouts'] ?? ['1/1']);
|
||||
$this->setSettings($params['settings'] ?? null);
|
||||
|
||||
@@ -78,15 +79,17 @@ class LayoutField extends BlocksField
|
||||
'pattern' => 'layout',
|
||||
'method' => 'POST',
|
||||
'action' => function () use ($field) {
|
||||
$request = App::instance()->request();
|
||||
|
||||
$defaults = $field->attrsForm([])->data(true);
|
||||
$attrs = $field->attrsForm($defaults)->values();
|
||||
$columns = get('columns') ?? ['1/1'];
|
||||
$columns = $request->get('columns') ?? ['1/1'];
|
||||
|
||||
return Layout::factory([
|
||||
'attrs' => $attrs,
|
||||
'columns' => array_map(fn ($width) => [
|
||||
'blocks' => [],
|
||||
'id' => uuid(),
|
||||
'id' => Str::uuid(),
|
||||
'width' => $width,
|
||||
], $columns)
|
||||
])->toArray();
|
||||
|
3
kirby/src/Form/FieldClass.php
Normal file → Executable file
3
kirby/src/Form/FieldClass.php
Normal file → Executable file
@@ -3,6 +3,7 @@
|
||||
namespace Kirby\Form;
|
||||
|
||||
use Exception;
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\HasSiblings;
|
||||
use Kirby\Cms\ModelWithContent;
|
||||
use Kirby\Data\Data;
|
||||
@@ -144,7 +145,7 @@ abstract class FieldClass
|
||||
$this->setHelp($params['help'] ?? null);
|
||||
$this->setIcon($params['icon'] ?? null);
|
||||
$this->setLabel($params['label'] ?? null);
|
||||
$this->setModel($params['model'] ?? site());
|
||||
$this->setModel($params['model'] ?? App::instance()->site());
|
||||
$this->setName($params['name'] ?? null);
|
||||
$this->setPlaceholder($params['placeholder'] ?? null);
|
||||
$this->setRequired($params['required'] ?? false);
|
||||
|
0
kirby/src/Form/Fields.php
Normal file → Executable file
0
kirby/src/Form/Fields.php
Normal file → Executable file
0
kirby/src/Form/Form.php
Normal file → Executable file
0
kirby/src/Form/Form.php
Normal file → Executable file
0
kirby/src/Form/Mixin/EmptyState.php
Normal file → Executable file
0
kirby/src/Form/Mixin/EmptyState.php
Normal file → Executable file
0
kirby/src/Form/Mixin/Max.php
Normal file → Executable file
0
kirby/src/Form/Mixin/Max.php
Normal file → Executable file
0
kirby/src/Form/Mixin/Min.php
Normal file → Executable file
0
kirby/src/Form/Mixin/Min.php
Normal file → Executable file
3
kirby/src/Form/Options.php
Normal file → Executable file
3
kirby/src/Form/Options.php
Normal file → Executable file
@@ -144,6 +144,9 @@ class Options
|
||||
];
|
||||
}
|
||||
|
||||
// fallback for the text
|
||||
$option['text'] ??= $option['value'];
|
||||
|
||||
// translate the option text
|
||||
if (is_array($option['text']) === true) {
|
||||
$option['text'] = I18n::translate($option['text'], $option['text']);
|
||||
|
0
kirby/src/Form/OptionsApi.php
Normal file → Executable file
0
kirby/src/Form/OptionsApi.php
Normal file → Executable file
0
kirby/src/Form/OptionsQuery.php
Normal file → Executable file
0
kirby/src/Form/OptionsQuery.php
Normal file → Executable file
0
kirby/src/Form/Validations.php
Normal file → Executable file
0
kirby/src/Form/Validations.php
Normal file → Executable file
Reference in New Issue
Block a user