Upgrade to 3.5.1
This commit is contained in:
@@ -84,7 +84,10 @@ class Field extends Component
|
||||
*/
|
||||
public function api()
|
||||
{
|
||||
if (isset($this->options['api']) === true && is_callable($this->options['api']) === true) {
|
||||
if (
|
||||
isset($this->options['api']) === true &&
|
||||
is_a($this->options['api'], 'Closure') === true
|
||||
) {
|
||||
return $this->options['api']->call($this);
|
||||
}
|
||||
}
|
||||
@@ -107,11 +110,13 @@ class Field extends Component
|
||||
|
||||
if ($save === false) {
|
||||
return null;
|
||||
} elseif (is_callable($save) === true) {
|
||||
return $save->call($this, $value);
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (is_a($save, 'Closure') === true) {
|
||||
return $save->call($this, $value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,16 +212,19 @@ class Field extends Component
|
||||
],
|
||||
'computed' => [
|
||||
'after' => function () {
|
||||
/** @var \Kirby\Form\Field $this */
|
||||
if ($this->after !== null) {
|
||||
return $this->model()->toString($this->after);
|
||||
}
|
||||
},
|
||||
'before' => function () {
|
||||
/** @var \Kirby\Form\Field $this */
|
||||
if ($this->before !== null) {
|
||||
return $this->model()->toString($this->before);
|
||||
}
|
||||
},
|
||||
'default' => function () {
|
||||
/** @var \Kirby\Form\Field $this */
|
||||
if ($this->default === null) {
|
||||
return;
|
||||
}
|
||||
@@ -228,6 +236,7 @@ class Field extends Component
|
||||
return $this->model()->toString($this->default);
|
||||
},
|
||||
'help' => function () {
|
||||
/** @var \Kirby\Form\Field $this */
|
||||
if ($this->help) {
|
||||
$help = $this->model()->toString($this->help);
|
||||
$help = $this->kirby()->kirbytext($help);
|
||||
@@ -235,11 +244,13 @@ class Field extends Component
|
||||
}
|
||||
},
|
||||
'label' => function () {
|
||||
/** @var \Kirby\Form\Field $this */
|
||||
if ($this->label !== null) {
|
||||
return $this->model()->toString($this->label);
|
||||
}
|
||||
},
|
||||
'placeholder' => function () {
|
||||
/** @var \Kirby\Form\Field $this */
|
||||
if ($this->placeholder !== null) {
|
||||
return $this->model()->toString($this->placeholder);
|
||||
}
|
||||
@@ -350,13 +361,13 @@ class Field extends Component
|
||||
*/
|
||||
public function kirby()
|
||||
{
|
||||
return $this->model->kirby();
|
||||
return $this->model()->kirby();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent model
|
||||
*
|
||||
* @return mixed|null
|
||||
* @return mixed
|
||||
*/
|
||||
public function model()
|
||||
{
|
||||
|
@@ -20,8 +20,10 @@ class BlocksField extends FieldClass
|
||||
use Max;
|
||||
use Min;
|
||||
|
||||
protected $fieldsets;
|
||||
protected $blocks;
|
||||
protected $fieldsets;
|
||||
protected $group;
|
||||
protected $pretty;
|
||||
protected $value = [];
|
||||
|
||||
public function __construct(array $params = [])
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Kirby\Form\Field;
|
||||
|
||||
use Kirby\Cms\Blueprint;
|
||||
use Kirby\Cms\Fieldset;
|
||||
use Kirby\Cms\Form;
|
||||
use Kirby\Cms\Layout;
|
||||
@@ -19,7 +20,7 @@ class LayoutField extends BlocksField
|
||||
{
|
||||
$this->setModel($params['model'] ?? site());
|
||||
$this->setLayouts($params['layouts'] ?? ['1/1']);
|
||||
$this->setSettings($params['settings'] ?? []);
|
||||
$this->setSettings($params['settings'] ?? null);
|
||||
|
||||
parent::__construct($params);
|
||||
}
|
||||
@@ -120,13 +121,15 @@ class LayoutField extends BlocksField
|
||||
}, $layouts);
|
||||
}
|
||||
|
||||
protected function setSettings(array $settings = [])
|
||||
protected function setSettings($settings = null)
|
||||
{
|
||||
if (empty($settings) === true) {
|
||||
$this->settings = null;
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = Blueprint::extend($settings);
|
||||
|
||||
$settings['icon'] = 'dashboard';
|
||||
$settings['type'] = 'layout';
|
||||
$settings['parent'] = $this->model();
|
||||
|
@@ -353,6 +353,7 @@ abstract class FieldClass
|
||||
'saveable' => $this->isSaveable(),
|
||||
'translate' => $this->translate(),
|
||||
'type' => $this->type(),
|
||||
'when' => $this->when(),
|
||||
'width' => $this->width(),
|
||||
];
|
||||
}
|
||||
@@ -614,6 +615,16 @@ abstract class FieldClass
|
||||
return Data::encode($value, 'yaml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditions when the field will be shown
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function when(): ?array
|
||||
{
|
||||
return $this->when;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the field in
|
||||
* the Panel grid
|
||||
|
@@ -29,6 +29,7 @@ class Options
|
||||
return [
|
||||
'Kirby\Cms\File' => 'file',
|
||||
'Kirby\Toolkit\Obj' => 'arrayItem',
|
||||
'Kirby\Cms\Block' => 'block',
|
||||
'Kirby\Cms\Page' => 'page',
|
||||
'Kirby\Cms\StructureObject' => 'structureItem',
|
||||
'Kirby\Cms\User' => 'user',
|
||||
@@ -169,6 +170,7 @@ class Options
|
||||
// default text setup
|
||||
$text = [
|
||||
'arrayItem' => '{{ arrayItem.value }}',
|
||||
'block' => '{{ block.type }}: {{ block.id }}',
|
||||
'file' => '{{ file.filename }}',
|
||||
'page' => '{{ page.title }}',
|
||||
'structureItem' => '{{ structureItem.title }}',
|
||||
@@ -178,6 +180,7 @@ class Options
|
||||
// default value setup
|
||||
$value = [
|
||||
'arrayItem' => '{{ arrayItem.value }}',
|
||||
'block' => '{{ block.id }}',
|
||||
'file' => '{{ file.id }}',
|
||||
'page' => '{{ page.id }}',
|
||||
'structureItem' => '{{ structureItem.id }}',
|
||||
|
Reference in New Issue
Block a user