From 6fcc1f225c0b2f0095d8d4106b1ed92ba6b37a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 3 Jun 2023 23:27:23 +0200 Subject: [PATCH 01/13] Allow radio form control to be unchecked --- src/Form/Control/Radio.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Form/Control/Radio.php b/src/Form/Control/Radio.php index 7fa02a7746..ad15838eb3 100644 --- a/src/Form/Control/Radio.php +++ b/src/Form/Control/Radio.php @@ -48,6 +48,10 @@ protected function renderView(): void $lister->tRow->dangerouslySetHtml('checked', $value === (string) $lister->model->getId() ? 'checked="checked"' : ''); }); + $this->js(true, null, '.ui.checkbox.radio')->checkbox([ + 'uncheckable' => !$this->entityField || ($this->entityField->getField()->nullable || !$this->entityField->getField()->required), + ]); + parent::renderView(); } From a7f8054680c6b8f5f654649076704ead869e319b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 4 Jun 2023 17:53:56 +0200 Subject: [PATCH 02/13] simplify input/textarea control templates --- src/Form/Control.php | 6 ++---- src/Form/Control/Input.php | 2 +- src/Form/Control/Textarea.php | 2 +- template/form/control/dropdown.html | 2 +- template/form/control/dropdown.pug | 2 +- template/form/control/input.html | 2 +- template/form/control/input.pug | 2 +- template/form/control/lookup.html | 2 +- template/form/control/lookup.pug | 2 +- tests/FormTest.php | 8 +++++++- 10 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Form/Control.php b/src/Form/Control.php index 76520944f1..0807a5fa79 100644 --- a/src/Form/Control.php +++ b/src/Form/Control.php @@ -64,14 +64,12 @@ class Control extends View public $hint; /** - * Is input field disabled? - * Disabled input fields are not editable and will not be submitted. + * Disabled field is not editable and will not be submitted. */ public bool $disabled = false; /** - * Is input field read only? - * Read only input fields are not editable, but will be submitted. + * Read-only field is not editable, but will be submitted. */ public bool $readOnly = false; diff --git a/src/Form/Control/Input.php b/src/Form/Control/Input.php index 9bb1aec90d..fd905b64f1 100644 --- a/src/Form/Control/Input.php +++ b/src/Form/Control/Input.php @@ -110,8 +110,8 @@ public function getInput() 'placeholder' => $this->inputType !== 'hidden' ? $this->placeholder : false, 'id' => $this->name . '_input', 'value' => $this->getValue(), - 'readonly' => $this->readOnly && $this->inputType !== 'hidden', 'disabled' => $this->disabled && $this->inputType !== 'hidden', + 'readonly' => $this->readOnly && $this->inputType !== 'hidden' && !$this->disabled, ], $this->inputAttr)); } diff --git a/src/Form/Control/Textarea.php b/src/Form/Control/Textarea.php index 9414f52967..1c5c54f638 100644 --- a/src/Form/Control/Textarea.php +++ b/src/Form/Control/Textarea.php @@ -16,8 +16,8 @@ public function getInput() 'rows' => $this->rows, 'placeholder' => $this->placeholder, 'id' => $this->name . '_input', - 'readonly' => $this->readOnly, 'disabled' => $this->disabled, + 'readonly' => $this->readOnly && !$this->disabled, ], $this->inputAttr), $this->getValue() ?? ''); } } diff --git a/template/form/control/dropdown.html b/template/form/control/dropdown.html index 7a5a7ce50b..c1cd5388c0 100644 --- a/template/form/control/dropdown.html +++ b/template/form/control/dropdown.html @@ -1,7 +1,7 @@
{$BeforeInput}{$AfterBeforeInput} -{Input}{/} +{$Input}
{DefaultText}...{/}