From 68bc1fffe75f433c972bdca1bb8229cd60227377 Mon Sep 17 00:00:00 2001 From: Michael Krecek Date: Tue, 2 Aug 2022 16:30:19 +0200 Subject: [PATCH 1/8] CamelCase readOnly control property --- demos/_includes/DemoLookup.php | 2 +- demos/form-control/input2.php | 18 +++++++++--------- demos/form-control/multiline.php | 2 +- src/Form.php | 2 +- src/Form/AbstractLayout.php | 2 +- src/Form/Control.php | 2 +- src/Form/Control/Calendar.php | 2 +- src/Form/Control/Checkbox.php | 4 ++-- src/Form/Control/Dropdown.php | 6 +++--- src/Form/Control/Input.php | 2 +- src/Form/Control/Lookup.php | 6 +++--- src/Form/Control/Radio.php | 4 ++-- src/Form/Control/Textarea.php | 2 +- src/Form/Control/TreeItemSelector.php | 2 +- src/Form/Control/Upload.php | 2 +- tests/ForFieldUiTest.php | 6 +++--- 16 files changed, 32 insertions(+), 32 deletions(-) diff --git a/demos/_includes/DemoLookup.php b/demos/_includes/DemoLookup.php index 53ae248224..443427b767 100644 --- a/demos/_includes/DemoLookup.php +++ b/demos/_includes/DemoLookup.php @@ -29,7 +29,7 @@ protected function initQuickNewRecord() $buttonSeed = is_string($buttonSeed) ? ['content' => $buttonSeed] : $buttonSeed; - $defaultSeed = [\Atk4\Ui\Button::class, 'class.disabled' => ($this->disabled || $this->readonly)]; + $defaultSeed = [\Atk4\Ui\Button::class, 'class.disabled' => ($this->disabled || $this->readOnly)]; $this->action = Factory::factory(array_merge($defaultSeed, (array) $buttonSeed)); diff --git a/demos/form-control/input2.php b/demos/form-control/input2.php index 6f77521198..47e9bbe7fe 100644 --- a/demos/form-control/input2.php +++ b/demos/form-control/input2.php @@ -14,24 +14,24 @@ /** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -\Atk4\Ui\Header::addTo($app, ['Disabled and read only form controls (normal / readonly / disabled)']); +\Atk4\Ui\Header::addTo($app, ['Disabled and read only form controls (normal / readOnly / disabled)']); $form = Form::addTo($app); // Test all kinds of input fields $group = $form->addGroup('Line'); $group->addControl('line_norm')->set('editable'); -$group->addControl('line_read', ['readonly' => true])->set('read only'); +$group->addControl('line_read', ['readOnly' => true])->set('read only'); $group->addControl('line_disb', ['disabled' => true])->set('disabled'); $group = $form->addGroup('Text Area'); $group->addControl('text_norm', [Form\Control\Textarea::class])->set('editable'); -$group->addControl('text_read', [Form\Control\Textarea::class, 'readonly' => true])->set('read only'); +$group->addControl('text_read', [Form\Control\Textarea::class, 'readOnly' => true])->set('read only'); $group->addControl('text_disb', [Form\Control\Textarea::class, 'disabled' => true])->set('disabled'); $group = $form->addGroup('Checkbox'); $group->addControl('c_norm', [Form\Control\Checkbox::class], ['type' => 'boolean'])->set(true); -$group->addControl('c_read', [Form\Control\Checkbox::class, 'readonly' => true], ['type' => 'boolean'])->set(true); // allows to change value +$group->addControl('c_read', [Form\Control\Checkbox::class, 'readOnly' => true], ['type' => 'boolean'])->set(true); // allows to change value $group->addControl('c_disb', [Form\Control\Checkbox::class, 'disabled' => true], ['type' => 'boolean'])->set(true); // input is not disabled $group = $form->addGroup('Dropdown'); @@ -42,13 +42,13 @@ 'file' => ['File', 'icon' => 'file icon'], ]; $group->addControl('d_norm', [Form\Control\Dropdown::class, 'values' => $values, 'width' => 'three'])->set('globe'); -$group->addControl('d_read', [Form\Control\Dropdown::class, 'values' => $values, 'readonly' => true, 'width' => 'three'])->set('globe'); // allows to change value +$group->addControl('d_read', [Form\Control\Dropdown::class, 'values' => $values, 'readOnly' => true, 'width' => 'three'])->set('globe'); // allows to change value $group->addControl('d_disb', [Form\Control\Dropdown::class, 'values' => $values, 'disabled' => true, 'width' => 'three'])->set('globe'); // css disabled, but can focus with Tab and change value $group = $form->addGroup('Radio'); $group->addControl('radio_norm', [Form\Control\Radio::class], ['enum' => ['one', 'two', 'three']])->set('two'); -$group->addControl('radio_read', [Form\Control\Radio::class, 'readonly' => true], ['enum' => ['one', 'two', 'three']])->set('two'); +$group->addControl('radio_read', [Form\Control\Radio::class, 'readOnly' => true], ['enum' => ['one', 'two', 'three']])->set('two'); $group->addControl('radio_disb', [Form\Control\Radio::class, 'disabled' => true], ['enum' => ['one', 'two', 'three']])->set('two'); $group = $form->addGroup('File upload'); @@ -62,7 +62,7 @@ $control->onDelete($onDelete); $control->onUpload($onUpload); -$control = $group->addControl('file_read', [Form\Control\Upload::class, ['accept' => ['.png', '.jpg'], 'readonly' => true]])->set('readonly', 'readonly.jpg'); +$control = $group->addControl('file_read', [Form\Control\Upload::class, ['accept' => ['.png', '.jpg'], 'readOnly' => true]])->set('readonly', 'readonly.jpg'); $control->onDelete($onDelete); $control->onUpload($onUpload); @@ -84,7 +84,7 @@ Form\Control\Lookup::class, 'model' => new Country($app->db), 'plus' => true, - 'readonly' => true, + 'readOnly' => true, ])->set($model->loadAny()->getId()); $group->addControl('Lookup_disb', [ @@ -97,7 +97,7 @@ $group = $form->addGroup('Calendar'); $group->addControl('date_norm', [Form\Control\Calendar::class, 'type' => 'date'])->set(new \DateTime()); -$group->addControl('date_read', [Form\Control\Calendar::class, 'type' => 'date', 'readonly' => true])->set(new \DateTime()); +$group->addControl('date_read', [Form\Control\Calendar::class, 'type' => 'date', 'readOnly' => true])->set(new \DateTime()); $group->addControl('date_disb', [Form\Control\Calendar::class, 'type' => 'date', 'disabled' => true])->set(new \DateTime()); $form->onSubmit(function (Form $form) { diff --git a/demos/form-control/multiline.php b/demos/form-control/multiline.php index 27ec8ac5c2..d0bf8a943b 100644 --- a/demos/form-control/multiline.php +++ b/demos/form-control/multiline.php @@ -101,7 +101,7 @@ protected function init(): void $sublayout = $form->layout->addSubLayout([Form\Layout\Section\Columns::class]); $sublayout->addColumn(12); $column = $sublayout->addColumn(4); -$controlTotal = $column->addControl('total', ['readonly' => true])->set($total); +$controlTotal = $column->addControl('total', ['readOnly' => true])->set($total); // Update total when qty and box value in any row has changed. $multiline->onLineChange(function ($rows, Form $form) use ($controlTotal) { diff --git a/src/Form.php b/src/Form.php index 88b749a364..b25b804c65 100644 --- a/src/Form.php +++ b/src/Form.php @@ -503,7 +503,7 @@ protected function loadPost() foreach ($this->controls as $k => $control) { try { // save field value only if field was editable in form at all - if (!$control->readonly && !$control->disabled) { + if (!$control->readOnly && !$control->disabled) { $control->set($this->getApp()->ui_persistence->typecastLoadField($control->entityField->getField(), $_POST[$k] ?? null)); } } catch (\Exception $e) { diff --git a/src/Form/AbstractLayout.php b/src/Form/AbstractLayout.php index b12e72a5cf..6e31a2e924 100644 --- a/src/Form/AbstractLayout.php +++ b/src/Form/AbstractLayout.php @@ -113,7 +113,7 @@ public function setModel(Model $model, array $fields = null): void if ($field->isEditable()) { $controls[] = [$field->shortName]; } elseif ($field->isVisible()) { - $controls[] = [$field->shortName, ['readonly' => true]]; + $controls[] = [$field->shortName, ['readOnly' => true]]; } } diff --git a/src/Form/Control.php b/src/Form/Control.php index 2806549b6a..197d8b86a1 100644 --- a/src/Form/Control.php +++ b/src/Form/Control.php @@ -70,7 +70,7 @@ class Control extends View * * @var bool */ - public $readonly = false; + public $readOnly = false; protected function init(): void { diff --git a/src/Form/Control/Calendar.php b/src/Form/Control/Calendar.php index c1182f2bc2..e1564372b2 100644 --- a/src/Form/Control/Calendar.php +++ b/src/Form/Control/Calendar.php @@ -55,7 +55,7 @@ protected function init(): void protected function renderView(): void { - if ($this->readonly) { + if ($this->readOnly) { $this->options['clickOpens'] = false; } diff --git a/src/Form/Control/Checkbox.php b/src/Form/Control/Checkbox.php index a5c123d88a..47c35f6500 100644 --- a/src/Form/Control/Checkbox.php +++ b/src/Form/Control/Checkbox.php @@ -66,8 +66,8 @@ protected function renderView(): void // We don't want this displayed, because it can only affect "checked" status anyway $this->content = null; - // take care of readonly status - if ($this->readonly) { + // take care of readOnly status + if ($this->readOnly) { $this->addClass('read-only'); } diff --git a/src/Form/Control/Dropdown.php b/src/Form/Control/Dropdown.php index e95e8307fc..83cd4bd7a7 100644 --- a/src/Form/Control/Dropdown.php +++ b/src/Form/Control/Dropdown.php @@ -136,7 +136,7 @@ public function getInput() 'type' => $this->inputType, 'id' => $this->name . '_input', 'value' => $this->getValue(), - 'readonly' => $this->readonly ? 'readonly' : false, + 'readOnly' => $this->readOnly ? 'readonly' : false, 'disabled' => $this->disabled ? 'disabled' : false, ], $this->inputAttr)); } @@ -252,7 +252,7 @@ protected function renderView(): void $this->addClass($this->defaultClass); - if ($this->readonly || $this->disabled) { + if ($this->readOnly || $this->disabled) { $this->setDropdownOption('showOnFocus', false); $this->setDropdownOption('allowTab', false); $this->removeClass('search'); @@ -265,7 +265,7 @@ protected function renderView(): void $this->addClass('disabled'); } - if ($this->readonly) { + if ($this->readOnly) { $this->setDropdownOption('allowTab', false); $this->setDropdownOption('onShow', new JsFunction([new JsExpression('return false')])); } diff --git a/src/Form/Control/Input.php b/src/Form/Control/Input.php index 960920ebd5..3d52fddab1 100644 --- a/src/Form/Control/Input.php +++ b/src/Form/Control/Input.php @@ -112,7 +112,7 @@ public function getInput() 'placeholder' => $this->placeholder, 'id' => $this->name . '_input', 'value' => $this->getValue(), - 'readonly' => $this->readonly ? 'readonly' : false, + 'readOnly' => $this->readOnly ? 'readonly' : false, 'disabled' => $this->disabled ? 'disabled' : false, ], $this->inputAttr)); } diff --git a/src/Form/Control/Lookup.php b/src/Form/Control/Lookup.php index 52591fbc04..085ee07b86 100644 --- a/src/Form/Control/Lookup.php +++ b/src/Form/Control/Lookup.php @@ -239,7 +239,7 @@ protected function initQuickNewRecord() $buttonSeed = ['content' => $buttonSeed]; } - $defaultSeed = [\Atk4\Ui\Button::class, 'class.disabled' => ($this->disabled || $this->readonly)]; + $defaultSeed = [\Atk4\Ui\Button::class, 'class.disabled' => ($this->disabled || $this->readOnly)]; $this->action = Factory::factory(array_merge($defaultSeed, $buttonSeed)); @@ -346,7 +346,7 @@ public function getInput() 'type' => 'hidden', 'id' => $this->name . '_input', 'value' => $this->getValue(), - 'readonly' => $this->readonly ? 'readonly' : false, + 'readOnly' => $this->readOnly ? 'readonly' : false, 'disabled' => $this->disabled ? 'disabled' : false, ], $this->inputAttr)); } @@ -393,7 +393,7 @@ protected function renderView(): void $this->template->set('disabled', 'disabled'); } - if ($this->readonly) { + if ($this->readOnly) { $this->settings['showOnFocus'] = false; $this->settings['allowTab'] = false; $this->settings['apiSettings'] = null; diff --git a/src/Form/Control/Radio.php b/src/Form/Control/Radio.php index 3fec20ee70..835c114c0e 100644 --- a/src/Form/Control/Radio.php +++ b/src/Form/Control/Radio.php @@ -40,13 +40,13 @@ protected function renderView(): void $this->lister->setModel($this->model); - // take care of readonly and disabled statuses + // take care of readOnly and disabled statuses if ($this->disabled) { $this->addClass('disabled'); } $this->lister->onHook(Lister::HOOK_BEFORE_ROW, function (Lister $lister) use ($value) { - if ($this->readonly) { + if ($this->readOnly) { $lister->t_row->set('disabled', $value !== (string) $lister->model->getId() ? 'disabled="disabled"' : ''); } elseif ($this->disabled) { $lister->t_row->set('disabled', 'disabled="disabled"'); diff --git a/src/Form/Control/Textarea.php b/src/Form/Control/Textarea.php index da284b1c93..1c8b6c7eb4 100644 --- a/src/Form/Control/Textarea.php +++ b/src/Form/Control/Textarea.php @@ -27,7 +27,7 @@ public function getInput() 'rows' => $this->rows, 'placeholder' => $this->placeholder, 'id' => $this->name . '_input', - 'readonly' => $this->readonly ? 'readonly' : false, + 'readOnly' => $this->readOnly ? 'readonly' : false, 'disabled' => $this->disabled ? 'disabled' : false, ], $this->inputAttr), (string) $this->getValue() // need to cast to string to avoid null values which break html markup diff --git a/src/Form/Control/TreeItemSelector.php b/src/Form/Control/TreeItemSelector.php index d2a0899c6a..59d5b6adab 100644 --- a/src/Form/Control/TreeItemSelector.php +++ b/src/Form/Control/TreeItemSelector.php @@ -120,7 +120,7 @@ public function getInput() 'name' => $this->shortName, 'type' => 'hidden', 'value' => $this->getValue(), - 'readonly' => true, + 'readOnly' => true, ]); } diff --git a/src/Form/Control/Upload.php b/src/Form/Control/Upload.php index 054c26e400..e79592581d 100644 --- a/src/Form/Control/Upload.php +++ b/src/Form/Control/Upload.php @@ -67,7 +67,7 @@ protected function init(): void $this->cb = \Atk4\Ui\JsCallback::addTo($this); if (!$this->action) { - $this->action = new \Atk4\Ui\Button(['icon' => 'upload', 'class.disabled' => ($this->disabled || $this->readonly)]); + $this->action = new \Atk4\Ui\Button(['icon' => 'upload', 'class.disabled' => ($this->disabled || $this->readOnly)]); } } diff --git a/tests/ForFieldUiTest.php b/tests/ForFieldUiTest.php index 1063cdc988..1cc95ebb85 100644 --- a/tests/ForFieldUiTest.php +++ b/tests/ForFieldUiTest.php @@ -45,7 +45,7 @@ public function testRegularField(): void $f = new \Atk4\Ui\Form(); $f->invokeInit(); $f->setModel($this->m->createEntity()); - $this->assertFalse($f->getControl('regular_field')->readonly); + $this->assertFalse($f->getControl('regular_field')->readOnly); } public function testJustDataField(): void @@ -53,7 +53,7 @@ public function testJustDataField(): void $f = new \Atk4\Ui\Form(); $f->invokeInit(); $f->setModel($this->m->createEntity(), ['just_for_data']); - $this->assertTrue($f->getControl('just_for_data')->readonly); + $this->assertTrue($f->getControl('just_for_data')->readOnly); } public function testShowInUi(): void @@ -61,6 +61,6 @@ public function testShowInUi(): void $f = new \Atk4\Ui\Form(); $f->invokeInit(); $f->setModel($this->m->createEntity()); - $this->assertFalse($f->getControl('no_persist_but_show_in_ui')->readonly); + $this->assertFalse($f->getControl('no_persist_but_show_in_ui')->readOnly); } } From 4e264980fd17a6fdd93310cd8dc1de90de0e8efb Mon Sep 17 00:00:00 2001 From: Michael Krecek Date: Tue, 2 Aug 2022 16:49:21 +0200 Subject: [PATCH 2/8] Strong type readOnly and disabled to boolean --- src/Form/Control.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Form/Control.php b/src/Form/Control.php index 197d8b86a1..4ba56f6d98 100644 --- a/src/Form/Control.php +++ b/src/Form/Control.php @@ -62,7 +62,7 @@ class Control extends View * * @var bool */ - public $disabled = false; + public bool $disabled = false; /** * Is input field read only? @@ -70,7 +70,7 @@ class Control extends View * * @var bool */ - public $readOnly = false; + public bool $readOnly = false; protected function init(): void { From 70d565461c0adeaa9ec8e86d69bddc0578774175 Mon Sep 17 00:00:00 2001 From: Michael Krecek Date: Tue, 2 Aug 2022 17:06:06 +0200 Subject: [PATCH 3/8] Changed demo description --- demos/form-control/input2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/form-control/input2.php b/demos/form-control/input2.php index 47e9bbe7fe..6aff09e6cb 100644 --- a/demos/form-control/input2.php +++ b/demos/form-control/input2.php @@ -14,7 +14,7 @@ /** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -\Atk4\Ui\Header::addTo($app, ['Disabled and read only form controls (normal / readOnly / disabled)']); +\Atk4\Ui\Header::addTo($app, ['Disabled and read only form controls (normal / read only / disabled)']); $form = Form::addTo($app); From c55e5d07d52e2106873d9ec25f5b21fbebf293df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 3 Aug 2022 05:18:34 +0200 Subject: [PATCH 4/8] fix cs --- src/Form/Control.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Form/Control.php b/src/Form/Control.php index 4ba56f6d98..3956a479e4 100644 --- a/src/Form/Control.php +++ b/src/Form/Control.php @@ -59,16 +59,12 @@ class Control extends View /** * Is input field disabled? * Disabled input fields are not editable and will not be submitted. - * - * @var bool */ public bool $disabled = false; /** * Is input field read only? * Read only input fields are not editable, but will be submitted. - * - * @var bool */ public bool $readOnly = false; From 610e6b7df4222252953821bf93230238944caa07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 3 Aug 2022 05:19:47 +0200 Subject: [PATCH 5/8] rm unuseful comment --- src/Form/Control/Checkbox.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Form/Control/Checkbox.php b/src/Form/Control/Checkbox.php index 47c35f6500..b1548a850e 100644 --- a/src/Form/Control/Checkbox.php +++ b/src/Form/Control/Checkbox.php @@ -50,9 +50,6 @@ protected function init(): void } } - /** - * Render view. - */ protected function renderView(): void { if ($this->label) { @@ -66,12 +63,10 @@ protected function renderView(): void // We don't want this displayed, because it can only affect "checked" status anyway $this->content = null; - // take care of readOnly status if ($this->readOnly) { $this->addClass('read-only'); } - // take care of disabled status if ($this->disabled) { $this->addClass('disabled'); $this->template->set('disabled', 'disabled="disabled"'); From b8d6a5be7a61007897ba2de08af2edddbadef364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 3 Aug 2022 05:24:49 +0200 Subject: [PATCH 6/8] revert case for HTML tags --- src/Form/Control/Dropdown.php | 2 +- src/Form/Control/Input.php | 2 +- src/Form/Control/Lookup.php | 2 +- src/Form/Control/Radio.php | 1 - src/Form/Control/Textarea.php | 2 +- src/Form/Control/TreeItemSelector.php | 2 +- 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Form/Control/Dropdown.php b/src/Form/Control/Dropdown.php index 83cd4bd7a7..55b76d6a92 100644 --- a/src/Form/Control/Dropdown.php +++ b/src/Form/Control/Dropdown.php @@ -136,7 +136,7 @@ public function getInput() 'type' => $this->inputType, 'id' => $this->name . '_input', 'value' => $this->getValue(), - 'readOnly' => $this->readOnly ? 'readonly' : false, + 'readonly' => $this->readOnly ? 'readonly' : false, 'disabled' => $this->disabled ? 'disabled' : false, ], $this->inputAttr)); } diff --git a/src/Form/Control/Input.php b/src/Form/Control/Input.php index 3d52fddab1..86ee7d85e0 100644 --- a/src/Form/Control/Input.php +++ b/src/Form/Control/Input.php @@ -112,7 +112,7 @@ public function getInput() 'placeholder' => $this->placeholder, 'id' => $this->name . '_input', 'value' => $this->getValue(), - 'readOnly' => $this->readOnly ? 'readonly' : false, + 'readonly' => $this->readOnly ? 'readonly' : false, 'disabled' => $this->disabled ? 'disabled' : false, ], $this->inputAttr)); } diff --git a/src/Form/Control/Lookup.php b/src/Form/Control/Lookup.php index 085ee07b86..b826345f6d 100644 --- a/src/Form/Control/Lookup.php +++ b/src/Form/Control/Lookup.php @@ -346,7 +346,7 @@ public function getInput() 'type' => 'hidden', 'id' => $this->name . '_input', 'value' => $this->getValue(), - 'readOnly' => $this->readOnly ? 'readonly' : false, + 'readonly' => $this->readOnly ? 'readonly' : false, 'disabled' => $this->disabled ? 'disabled' : false, ], $this->inputAttr)); } diff --git a/src/Form/Control/Radio.php b/src/Form/Control/Radio.php index 835c114c0e..cd232d7637 100644 --- a/src/Form/Control/Radio.php +++ b/src/Form/Control/Radio.php @@ -40,7 +40,6 @@ protected function renderView(): void $this->lister->setModel($this->model); - // take care of readOnly and disabled statuses if ($this->disabled) { $this->addClass('disabled'); } diff --git a/src/Form/Control/Textarea.php b/src/Form/Control/Textarea.php index 1c8b6c7eb4..81262f6286 100644 --- a/src/Form/Control/Textarea.php +++ b/src/Form/Control/Textarea.php @@ -27,7 +27,7 @@ public function getInput() 'rows' => $this->rows, 'placeholder' => $this->placeholder, 'id' => $this->name . '_input', - 'readOnly' => $this->readOnly ? 'readonly' : false, + 'readonly' => $this->readOnly ? 'readonly' : false, 'disabled' => $this->disabled ? 'disabled' : false, ], $this->inputAttr), (string) $this->getValue() // need to cast to string to avoid null values which break html markup diff --git a/src/Form/Control/TreeItemSelector.php b/src/Form/Control/TreeItemSelector.php index 59d5b6adab..d2a0899c6a 100644 --- a/src/Form/Control/TreeItemSelector.php +++ b/src/Form/Control/TreeItemSelector.php @@ -120,7 +120,7 @@ public function getInput() 'name' => $this->shortName, 'type' => 'hidden', 'value' => $this->getValue(), - 'readOnly' => true, + 'readonly' => true, ]); } From 73228a605f7af7902d6eb899826eaf5e9e6783aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 3 Aug 2022 05:44:31 +0200 Subject: [PATCH 7/8] fix docs --- docs/form-control.rst | 2 +- src/Form/AbstractLayout.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/form-control.rst b/docs/form-control.rst index c04b1eee4c..3524da4443 100644 --- a/docs/form-control.rst +++ b/docs/form-control.rst @@ -125,7 +125,7 @@ or you can inject a view with a custom template:: Read only and disabled form controls ------------------------------------ -.. php:attr:: readonly +.. php:attr:: readOnly Read only form controls can be seen in form, can be focused and will be submitted, but we don't allow to change their value. diff --git a/src/Form/AbstractLayout.php b/src/Form/AbstractLayout.php index 6e31a2e924..beffc50aa5 100644 --- a/src/Form/AbstractLayout.php +++ b/src/Form/AbstractLayout.php @@ -105,7 +105,7 @@ public function setModel(Model $model, array $fields = null): void $fields = $this->getModelFields($model); } - // prepare array of controls - check if fields are editable or readOnly/disabled + // prepare array of controls - check if fields are editable or read-only/disabled $controls = []; foreach ($fields as $fieldName) { $field = $model->getField($fieldName); From 8ca3c64e49be51d4b2f8b343ebce3f1480ea2566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 3 Aug 2022 05:46:14 +0200 Subject: [PATCH 8/8] improve/unrelated expectException CS --- tests/HtmlTemplateTest.php | 3 +++ tests/SessionTraitTest.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/HtmlTemplateTest.php b/tests/HtmlTemplateTest.php index 88c4a0560e..4f32514502 100644 --- a/tests/HtmlTemplateTest.php +++ b/tests/HtmlTemplateTest.php @@ -52,6 +52,7 @@ public function testGetTagTree(): void public function testGetTagRefNotFoundException(): void { $t = new HtmlTemplate('{foo}hello{/}'); + $this->expectException(Exception::class); $t->getTagTree('bar'); } @@ -59,6 +60,7 @@ public function testGetTagRefNotFoundException(): void public function testLoadFromFileNonExistentFileException(): void { $t = new HtmlTemplate(); + $this->expectException(Exception::class); $t->loadFromFile(__DIR__ . '/bad_template_file'); } @@ -80,6 +82,7 @@ public function testHasTag(): void public function testSetBadTypeException(): void { $t = new HtmlTemplate('{foo}hello{/} guys'); + $this->expectException(Exception::class); $t->set('foo', new \stdClass()); // @phpstan-ignore-line } diff --git a/tests/SessionTraitTest.php b/tests/SessionTraitTest.php index 752a918077..0530165e27 100644 --- a/tests/SessionTraitTest.php +++ b/tests/SessionTraitTest.php @@ -54,9 +54,10 @@ protected function tearDown(): void public function testException1(): void { + $m = new SessionWithoutNameMock($this->app); + // when try to start session without NameTrait $this->expectException(Exception::class); - $m = new SessionWithoutNameMock($this->app); $m->memorize('test', 'foo'); }