diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 5bc09afbe5..ce0a88d499 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -224,7 +224,7 @@ parameters: # TODO fix contravariance for View::set() method - path: 'src/Console.php' - message: '~^Parameter #1 \$fx \(Closure\(\$this\(Atk4\\Ui\\Console\)\): void\) of method Atk4\\Ui\\Console::set\(\) should be contravariant with parameter \$arg1 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' + message: '~^Parameter #1 \$fx \(Closure\(\$this\): void\) of method Atk4\\Ui\\Console::set\(\) should be contravariant with parameter \$arg1 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' - path: 'src/Console.php' message: '~^Parameter #2 \$event \(bool\|string\) of method Atk4\\Ui\\Console::set\(\) should be contravariant with parameter \$arg2 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' @@ -233,16 +233,16 @@ parameters: message: '~^Parameter #2 \$ignore \(\*NEVER\*\) of method Atk4\\Ui\\Form\\Control::set\(\) should be compatible with parameter \$arg2 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' - path: 'src/Form/Control/Calendar.php' - message: '~^Parameter #1 \$expr \(Atk4\\Ui\\Js\\JsExpressionable\) of method Atk4\\Ui\\Form\\Control\\Calendar::onChange\(\) should be contravariant with parameter \$expr \(array{Closure\(Atk4\\Ui\\Js\\Jquery, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): Atk4\\Ui\\Js\\JsExpressionable\|Atk4\\Ui\\View\|string\|void}\|Atk4\\Ui\\Js\\JsExpressionable\|\(Closure\(Atk4\\Ui\\Js\\Jquery, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): Atk4\\Ui\\Js\\JsExpressionable\|Atk4\\Ui\\View\|string\|void\)\) of method Atk4\\Ui\\Form\\Control::onChange\(\)$~' + message: '~^Parameter #1 \$expr \(Atk4\\Ui\\Js\\JsExpressionable\) of method Atk4\\Ui\\Form\\Control\\Calendar::onChange\(\) should be contravariant with parameter \$expr \(array\{Closure\(Atk4\\Ui\\Js\\Jquery, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): \(Atk4\\Ui\\Js\\JsExpressionable\|Atk4\\Ui\\View\|string\|void\)\}\|Atk4\\Ui\\Js\\JsExpressionable\|\(Closure\(Atk4\\Ui\\Js\\Jquery, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): \(Atk4\\Ui\\Js\\JsExpressionable\|Atk4\\Ui\\View\|string\|void\)\)\) of method Atk4\\Ui\\Form\\Control::onChange\(\)$~' - path: 'src/Form/Control/Upload.php' message: '~^Parameter #1 \$fileId \(string\) of method Atk4\\Ui\\Form\\Control\\Upload::set\(\) should be contravariant with parameter \$value \(mixed\) of method Atk4\\Ui\\Form\\Control::set\(\)$~' - path: 'src/JsCallback.php' - message: '~^Parameter #1 \$fx \(Closure\(Atk4\\Ui\\Js\\Jquery, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): Atk4\\Ui\\Js\\JsExpressionable\|Atk4\\Ui\\View\|string\|void\) of method Atk4\\Ui\\JsCallback::set\(\) should be contravariant with parameter \$fx \(Closure\(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): mixed\) of method Atk4\\Ui\\Callback::set\(\)$~' + message: '~^Parameter #1 \$fx \(Closure\(Atk4\\Ui\\Js\\Jquery, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): \(Atk4\\Ui\\Js\\JsExpressionable\|Atk4\\Ui\\View\|string\|void\)\) of method Atk4\\Ui\\JsCallback::set\(\) should be contravariant with parameter \$fx \(Closure\(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): mixed\) of method Atk4\\Ui\\Callback::set\(\)$~' - path: 'src/Loader.php' - message: '~^Parameter #1 \$fx \(Closure\(\$this\(Atk4\\Ui\\Loader\)\): void\) of method Atk4\\Ui\\Loader::set\(\) should be contravariant with parameter \$arg1 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' + message: '~^Parameter #1 \$fx \(Closure\(\$this\): void\) of method Atk4\\Ui\\Loader::set\(\) should be contravariant with parameter \$arg1 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' - path: 'src/Loader.php' message: '~^Parameter #2 \$ignore \(\*NEVER\*\) of method Atk4\\Ui\\Loader::set\(\) should be compatible with parameter \$arg2 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' @@ -260,10 +260,10 @@ parameters: message: '~^Parameter #2 \$ignore \(\*NEVER\*\) of method Atk4\\Ui\\Popup::set\(\) should be compatible with parameter \$arg2 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' - path: 'src/VirtualPage.php' - message: '~^Parameter #1 \$fx \(Closure\(\$this\(Atk4\\Ui\\VirtualPage\), mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): void\) of method Atk4\\Ui\\VirtualPage::set\(\) should be contravariant with parameter \$arg1 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' + message: '~^Parameter #1 \$fx \(Closure\(\$this, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): void\) of method Atk4\\Ui\\VirtualPage::set\(\) should be contravariant with parameter \$arg1 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' - path: 'src/VirtualPage.php' - message: '~^Parameter #1 \$fx of method Atk4\\Ui\\Callback::set\(\) expects \(Closure\(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): void\)\|null, Closure\(\$this\(Atk4\\Ui\\VirtualPage\), mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): void given.$~' + message: '~^Parameter #1 \$fx of method Atk4\\Ui\\Callback::set\(\) expects \(Closure\(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): void\)\|null, Closure\(\$this, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed\): void given\.$~' - path: 'src/VirtualPage.php' message: '~^Parameter #2 \$fxArgs \(array\) of method Atk4\\Ui\\VirtualPage::set\(\) should be contravariant with parameter \$arg2 \(mixed\) of method Atk4\\Ui\\View::set\(\)$~' 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/Checkbox.php b/src/Form/Control/Checkbox.php index 2aeff32e08..53c554877a 100644 --- a/src/Form/Control/Checkbox.php +++ b/src/Form/Control/Checkbox.php @@ -63,13 +63,12 @@ protected function renderView(): void $this->content = null; - if ($this->readOnly) { - $this->addClass('read-only'); - } - if ($this->disabled) { $this->addClass('disabled'); $this->template->dangerouslySetHtml('disabled', 'disabled="disabled"'); + } elseif ($this->readOnly) { + $this->addClass('read-only'); + $this->template->dangerouslySetHtml('disabled', 'readonly="readonly"'); } $this->js(true)->checkbox(); diff --git a/src/Form/Control/Dropdown.php b/src/Form/Control/Dropdown.php index 00a1777cfb..ac3d41b8f1 100644 --- a/src/Form/Control/Dropdown.php +++ b/src/Form/Control/Dropdown.php @@ -5,13 +5,13 @@ namespace Atk4\Ui\Form\Control; use Atk4\Ui\HtmlTemplate; +use Atk4\Ui\Js\Jquery; use Atk4\Ui\Js\JsExpression; use Atk4\Ui\Js\JsExpressionable; use Atk4\Ui\Js\JsFunction; class Dropdown extends Input { - public $ui = 'dropdown fluid search selection'; public $defaultTemplate = 'form/control/dropdown.html'; public string $inputType = 'hidden'; @@ -33,16 +33,6 @@ class Dropdown extends Input /** @var string The string to set as an empty values. */ public $empty = "\u{00a0}"; // Unicode NBSP - /** - * The icon to display at the dropdown menu. - * The template default is set to: 'dropdown'. - * Note: dropdown icon is show on the right side of the menu - * while other icon are usually display on the left side. - * - * @var string|null - */ - public $dropIcon; - /** @var array Dropdown options as per Fomantic-UI dropdown options. */ public $dropdownOptions = []; @@ -175,12 +165,23 @@ public function setDropdownOptions($options): void $this->dropdownOptions = array_merge($this->dropdownOptions, $options); } + /** + * @param bool|string $when + * @param JsExpressionable $action + * + * @return Jquery + */ + protected function jsDropdown($when = false, $action = null): JsExpressionable + { + return $this->js($when, $action, 'div.ui.dropdown:has(> #' . $this->name . '_input)'); + } + /** * Render JS for dropdown. */ protected function jsRenderDropdown(): JsExpressionable { - return $this->js(true)->dropdown($this->dropdownOptions); + return $this->jsDropdown(true)->dropdown($this->dropdownOptions); } /** @@ -220,31 +221,28 @@ protected function htmlRenderValue(): void protected function renderView(): void { if ($this->multiple) { - $this->addClass('multiple'); + $this->template->dangerouslySetHtml('multipleClass', 'multiple'); } if ($this->readOnly || $this->disabled) { $this->setDropdownOption('allowTab', false); - $this->removeClass('search'); if ($this->multiple) { - $this->js(true)->find('a i.delete.icon')->attr('class', 'disabled'); + $this->jsDropdown(true)->find('a i.delete.icon')->attr('class', 'disabled'); } } if ($this->disabled) { - $this->addClass('disabled'); - } + $this->template->set('disabledClass', 'disabled'); + $this->template->dangerouslySetHtml('disabled', 'disabled="disabled"'); + } elseif ($this->readOnly) { + $this->template->set('disabledClass', 'read-only'); + $this->template->dangerouslySetHtml('disabled', 'readonly="readonly"'); - if ($this->readOnly) { $this->setDropdownOption('allowTab', false); $this->setDropdownOption('onShow', new JsFunction([], [new JsExpression('return false')])); } - if ($this->dropIcon) { - $this->template->trySet('DropIcon', $this->dropIcon); - } - - $this->template->trySet('DefaultText', $this->empty); + $this->template->set('DefaultText', $this->empty); $this->htmlRenderValue(); $this->jsRenderDropdown(); diff --git a/src/Form/Control/DropdownCascade.php b/src/Form/Control/DropdownCascade.php index 7331e9b004..9d784c6902 100644 --- a/src/Form/Control/DropdownCascade.php +++ b/src/Form/Control/DropdownCascade.php @@ -43,12 +43,12 @@ protected function init(): void $expr = [ function (Jquery $j) use ($cascadeFromValue) { return new JsBlock([ - $this->js()->dropdown('change values', $this->getNewValues($cascadeFromValue)), - $this->js()->removeClass('loading'), + $this->jsDropdown()->dropdown('change values', $this->getNewValues($cascadeFromValue)), + $this->jsDropdown()->removeClass('loading'), ]); }, - $this->js()->dropdown('clear'), - $this->js()->addClass('loading'), + $this->jsDropdown()->dropdown('clear'), + $this->jsDropdown()->addClass('loading'), ]; $this->cascadeFrom->onChange($expr, ['args' => [$this->cascadeFrom->name => $this->cascadeFrom->jsInput()->val()]]); 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/Lookup.php b/src/Form/Control/Lookup.php index b12b13c406..bddf76923f 100644 --- a/src/Form/Control/Lookup.php +++ b/src/Form/Control/Lookup.php @@ -13,6 +13,7 @@ use Atk4\Ui\Js\Jquery; use Atk4\Ui\Js\JsBlock; use Atk4\Ui\Js\JsExpression; +use Atk4\Ui\Js\JsExpressionable; use Atk4\Ui\Js\JsFunction; use Atk4\Ui\Js\JsModal; use Atk4\Ui\Js\JsToast; @@ -130,7 +131,6 @@ protected function init(): void parent::init(); $this->template->set([ - 'inputId' => $this->name . '-ac', 'placeholder' => $this->placeholder, ]); @@ -142,6 +142,17 @@ protected function init(): void }); } + /** + * @param bool|string $when + * @param JsExpressionable $action + * + * @return Jquery + */ + protected function jsDropdown($when = false, $action = null): JsExpressionable + { + return $this->js($when, $action, 'div.ui.dropdown:has(> #' . $this->name . '_input)'); + } + /** * Returns URL which would respond with first 50 matching records. */ @@ -261,7 +272,7 @@ protected function initQuickNewRecord(): void $res->addStatement((new Jquery())->closest('.atk-modal')->modal('hide')); $row = $this->renderRow($form->model); - $chain = new Jquery('#' . $this->name . '-ac'); + $chain = $this->jsDropdown(); $chain->dropdown('set value', $row['value'])->dropdown('set text', $row['title']); $res->addStatement($chain); @@ -352,17 +363,17 @@ protected function renderView(): void } if ($this->disabled) { - $this->settings['allowTab'] = false; - - $this->template->dangerouslySetHtml('disabled', 'disabled="disabled"'); $this->template->set('disabledClass', 'disabled'); - } + $this->template->dangerouslySetHtml('disabled', 'disabled="disabled"'); + + $this->settings['allowTab'] = false; + } elseif ($this->readOnly) { + $this->template->set('disabledClass', 'read-only'); + $this->template->dangerouslySetHtml('disabled', 'readonly="readonly"'); - if ($this->readOnly) { $this->settings['allowTab'] = false; $this->settings['apiSettings'] = null; $this->settings['onShow'] = new JsFunction([], [new JsExpression('return false')]); - $this->template->dangerouslySetHtml('readonly', 'readonly="readonly"'); } if ($this->dependency) { @@ -371,7 +382,7 @@ protected function renderView(): void ], $this->apiConfig['data'] ?? []); } - $chain = new Jquery('#' . $this->name . '-ac'); + $chain = $this->jsDropdown(); $this->initDropdown($chain); diff --git a/src/Form/Control/Radio.php b/src/Form/Control/Radio.php index 7fa02a7746..121f71bdf3 100644 --- a/src/Form/Control/Radio.php +++ b/src/Form/Control/Radio.php @@ -39,15 +39,21 @@ protected function renderView(): void $this->lister->setModel($this->model); $this->lister->onHook(Lister::HOOK_BEFORE_ROW, function (Lister $lister) use ($value) { - if ($this->readOnly) { - $lister->tRow->dangerouslySetHtml('disabled', $value !== (string) $lister->model->getId() ? 'disabled="disabled"' : ''); - } elseif ($this->disabled) { + if ($this->disabled) { + $lister->tRow->dangerouslySetHtml('disabledClass', 'disabled'); $lister->tRow->dangerouslySetHtml('disabled', 'disabled="disabled"'); + } elseif ($this->readOnly) { + $lister->tRow->dangerouslySetHtml('disabledClass', 'read-only'); + $lister->tRow->dangerouslySetHtml('disabled', 'readonly="readonly"'); } - $lister->tRow->dangerouslySetHtml('checked', $value === (string) $lister->model->getId() ? 'checked="checked"' : ''); + $lister->tRow->dangerouslySetHtml('checked', $lister->model->compare($lister->model->idField, $value) ? 'checked="checked"' : ''); }); + $this->js(true, null, '.ui.checkbox.radio')->checkbox([ + 'uncheckable' => !$this->entityField || ($this->entityField->getField()->nullable || !$this->entityField->getField()->required), + ]); + parent::renderView(); } 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/src/Form/Control/Upload.php b/src/Form/Control/Upload.php index f979cdf90d..d6d6b02213 100644 --- a/src/Form/Control/Upload.php +++ b/src/Form/Control/Upload.php @@ -65,8 +65,11 @@ protected function init(): void $this->cb = JsCallback::addTo($this); - if (!$this->action) { - $this->action = new Button(['icon' => 'upload', 'class.disabled' => $this->disabled || $this->readOnly]); + if ($this->action === null) { + $this->action = new Button([ + 'icon' => 'upload', + 'class.disabled' => $this->disabled || $this->readOnly, + ]); } } @@ -123,10 +126,8 @@ public function setFileId($id): void /** * Add a JS action to be returned to server on callback. - * - * @param JsExpressionable $action */ - public function addJsAction($action): void + public function addJsAction(JsExpressionable $action): void { $this->jsActions[] = $action; } @@ -162,7 +163,10 @@ public function onUpload(\Closure $fx): void $this->setInput($fileId); } - $this->addJsAction($fx(...$postFiles)); + $jsRes = $fx(...$postFiles); + if ($jsRes !== null) { // @phpstan-ignore-line https://github.com/phpstan/phpstan/issues/9388 + $this->addJsAction($jsRes); + } if (count($postFiles) > 0 && reset($postFiles)['error'] === 0) { $this->addJsAction( @@ -186,7 +190,11 @@ public function onDelete(\Closure $fx): void if (($_POST['fUploadAction'] ?? null) === self::DELETE_ACTION) { $this->cb->set(function () use ($fx) { $fileId = $_POST['fUploadId']; - $this->addJsAction($fx($fileId)); + + $jsRes = $fx($fileId); + if ($jsRes !== null) { // @phpstan-ignore-line https://github.com/phpstan/phpstan/issues/9388 + $this->addJsAction($jsRes); + } return new JsBlock($this->jsActions); }); @@ -195,10 +203,6 @@ public function onDelete(\Closure $fx): void protected function renderView(): void { - // need before parent rendering. - if ($this->disabled) { - $this->addClass('disabled'); - } parent::renderView(); if ($this->cb->canTerminate()) { @@ -222,8 +226,10 @@ protected function renderView(): void $this->template->dangerouslySetHtml('multiple', 'multiple="multiple"'); } + $this->template->set('placeholderReadonly', $this->disabled ? 'disabled="disabled"' : 'readonly="readonly"'); + if ($this->placeholder) { - $this->template->trySet('PlaceHolder', $this->placeholder); + $this->template->set('Placeholder', $this->placeholder); } $this->js(true)->atkFileUpload([ diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index 7ea1cc1bca..2a4cb8c7e7 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -11,12 +11,7 @@ class UploadImage extends Upload /** @var View|null The thumbnail view to add to this input. */ public $thumbnail; - /** - * The template region where to add the thumbnail view. - * Default to AfterAfterInput. - * - * @var string - */ + /** @var string The template region where to add the thumbnail view. */ public $thumbnailRegion = 'AfterAfterInput'; /** @var string|null The default thumbnail source. */ @@ -53,9 +48,9 @@ public function getThumbnail(): View public function setThumbnailSrc(string $src): void { $this->thumbnail->setAttr(['src' => $src]); - $action = $this->thumbnail->js(); - $action->attr('src', $src); - $this->addJsAction($action); + $js = $this->thumbnail->js(); + $js->attr('src', $src); + $this->addJsAction($js); } /** @@ -63,12 +58,12 @@ public function setThumbnailSrc(string $src): void */ public function clearThumbnail(): void { - $action = $this->thumbnail->js(); + $js = $this->thumbnail->js(); if ($this->defaultSrc !== null) { - $action->attr('src', $this->defaultSrc); + $js->attr('src', $this->defaultSrc); } else { - $action->removeAttr('src'); + $js->removeAttr('src'); } - $this->addJsAction($action); + $this->addJsAction($js); } } diff --git a/src/Grid.php b/src/Grid.php index 4afaf72516..e4ec1f3481 100644 --- a/src/Grid.php +++ b/src/Grid.php @@ -244,7 +244,7 @@ public function addItemsPerPageSelector($items = [10, 25, 50, 100], $label = 'It * * @param int $ipp number of item per page to start with * @param array $options an array with JS Scroll plugin options - * @param View $container The container holding the lister for scrolling purpose. Default to view owner. + * @param View $container the container holding the lister for scrolling purpose * @param string $scrollRegion A specific template region to render. Render output is append to container HTML element. * * @return $this @@ -275,7 +275,7 @@ public function addJsPaginator($ipp, $options = [], $container = null, $scrollRe * @param int $ipp number of item per page to start with * @param int $containerHeight number of pixel the table container should be * @param array $options an array with JS Scroll plugin options - * @param View $container The container holding the lister for scrolling purpose. Default to view owner. + * @param View $container the container holding the lister for scrolling purpose * @param string $scrollRegion A specific template region to render. Render output is append to container HTML element. * * @return $this diff --git a/src/JsSearch.php b/src/JsSearch.php index da60b7774a..6f3bd7c269 100644 --- a/src/JsSearch.php +++ b/src/JsSearch.php @@ -48,7 +48,7 @@ class JsSearch extends View * If search query need to be control via an URL parameter only * set this to false. * - * @var bool default to true + * @var bool */ public $useAjax = true; diff --git a/src/Lister.php b/src/Lister.php index 4330ddb937..8da2a993ae 100644 --- a/src/Lister.php +++ b/src/Lister.php @@ -73,12 +73,12 @@ protected function initChunks(): void /** * Add Dynamic paginator when scrolling content via Javascript. - * Will output x item in lister set per ipp until user scroll content to the end of page. + * Will output x item in lister set per IPP until user scroll content to the end of page. * When this happen, content will be reload x number of items. * * @param int $ipp Number of item per page * @param array $options an array with JS Scroll plugin options - * @param View $container The container holding the lister for scrolling purpose. Default to view owner. + * @param View $container the container holding the lister for scrolling purpose * @param string $scrollRegion A specific template region to render. Render output is append to container HTML element. * * @return $this diff --git a/src/Table.php b/src/Table.php index 188045dbfa..c9e3714909 100644 --- a/src/Table.php +++ b/src/Table.php @@ -336,7 +336,7 @@ public function resizableColumn($fx = null, $widths = null, $resizerOptions = [] * * @param int $ipp number of item per page to start with * @param array $options an array with JS Scroll plugin options - * @param View $container The container holding the lister for scrolling purpose. Default to view owner. + * @param View $container the container holding the lister for scrolling purpose * @param string $scrollRegion A specific template region to render. Render output is append to container HTML element. * * @return $this diff --git a/template/form/control/checkbox.html b/template/form/control/checkbox.html index 16d3f004e3..28c2983528 100644 --- a/template/form/control/checkbox.html +++ b/template/form/control/checkbox.html @@ -1,5 +1,5 @@
- +
diff --git a/template/form/control/checkbox.pug b/template/form/control/checkbox.pug index 6b738d445a..d41989fdb6 100644 --- a/template/form/control/checkbox.pug +++ b/template/form/control/checkbox.pug @@ -1,5 +1,5 @@ |
-| +| | |
= "\n" diff --git a/template/form/control/dropdown.html b/template/form/control/dropdown.html index 7a5a7ce50b..5264babab1 100644 --- a/template/form/control/dropdown.html +++ b/template/form/control/dropdown.html @@ -1,12 +1,15 @@
{$BeforeInput}{$AfterBeforeInput} -{Input}{/} - -
{DefaultText}...{/}
+ {$AfterInput}{$AfterAfterInput}
diff --git a/template/form/control/dropdown.pug b/template/form/control/dropdown.pug index 7c032bcd26..f1b5f4bf5e 100644 --- a/template/form/control/dropdown.pug +++ b/template/form/control/dropdown.pug @@ -1,12 +1,15 @@ |
| {$BeforeInput}{$AfterBeforeInput} -| {Input}{/} -| -|
{DefaultText}...{/}
+| | {$AfterInput}{$AfterAfterInput} |
= "\n" diff --git a/template/form/control/input.html b/template/form/control/input.html index 264ed94077..26fd56141a 100644 --- a/template/form/control/input.html +++ b/template/form/control/input.html @@ -1,4 +1,4 @@
-{$BeforeInput}{$AfterBeforeInput}{Input}{/}{$AfterInput}{$AfterAfterInput} +{$BeforeInput}{$AfterBeforeInput}{$Input}{$AfterInput}{$AfterAfterInput}
diff --git a/template/form/control/input.pug b/template/form/control/input.pug index c3fab13310..7e9626df61 100644 --- a/template/form/control/input.pug +++ b/template/form/control/input.pug @@ -1,4 +1,4 @@ |
-| {$BeforeInput}{$AfterBeforeInput}{Input}{/}{$AfterInput}{$AfterAfterInput} +| {$BeforeInput}{$AfterBeforeInput}{$Input}{$AfterInput}{$AfterAfterInput} |
= "\n" diff --git a/template/form/control/lookup.html b/template/form/control/lookup.html index 23e90a0710..ea57f55456 100644 --- a/template/form/control/lookup.html +++ b/template/form/control/lookup.html @@ -1,11 +1,11 @@
{$BeforeInput}{$AfterBeforeInput} - diff --git a/template/form/control/lookup.pug b/template/form/control/lookup.pug index 57725c7f08..99f2cc9c94 100644 --- a/template/form/control/lookup.pug +++ b/template/form/control/lookup.pug @@ -1,10 +1,10 @@ |
| {$BeforeInput}{$AfterBeforeInput} -| diff --git a/template/form/control/radio.html b/template/form/control/radio.html index f985de3a98..94e4286c24 100644 --- a/template/form/control/radio.html +++ b/template/form/control/radio.html @@ -1,7 +1,7 @@
{Radio}{rows}{row} -
+
diff --git a/template/form/control/radio.pug b/template/form/control/radio.pug index 28497c5ed8..b2d741e437 100644 --- a/template/form/control/radio.pug +++ b/template/form/control/radio.pug @@ -1,6 +1,6 @@ |
| {Radio}{rows}{row} -|
+|
| | |
diff --git a/template/form/control/upload.html b/template/form/control/upload.html index de76c98a6e..fc45fe2711 100644 --- a/template/form/control/upload.html +++ b/template/form/control/upload.html @@ -3,14 +3,14 @@ {$AboveInput}
{$BeforeInput}{$AfterBeforeInput} -
- -{Input}{/} - +
+ +{$Input} +
{$AfterInput}{$AfterAfterInput}
-
+ diff --git a/template/form/control/upload.pug b/template/form/control/upload.pug index 36d969c473..07114a47a1 100644 --- a/template/form/control/upload.pug +++ b/template/form/control/upload.pug @@ -2,14 +2,14 @@ | {$AboveInput} |
| {$BeforeInput}{$AfterBeforeInput} -|
-| -| {Input}{/} -| +|
+| +| {$Input} +| |
| {$AfterInput}{$AfterAfterInput} |
-|
+| diff --git a/tests/ForFieldUiTest.php b/tests/FormFieldUiTest.php similarity index 97% rename from tests/ForFieldUiTest.php rename to tests/FormFieldUiTest.php index 994f8c2940..a136e1d028 100644 --- a/tests/ForFieldUiTest.php +++ b/tests/FormFieldUiTest.php @@ -25,7 +25,7 @@ protected function init(): void * Test is designed to verify that field which is explicitly editable should appear and be editable * even if 'neverPersist' is set to true. */ -class ForFieldUiTest extends TestCase +class FormFieldUiTest extends TestCase { use CreateAppTrait; diff --git a/tests/FormTest.php b/tests/FormTest.php index ac21ae8349..85a6a42d50 100644 --- a/tests/FormTest.php +++ b/tests/FormTest.php @@ -224,12 +224,18 @@ public function testSubmitNonFormFieldError(): void public function testNoDisabledAttrWithHiddenType(): void { + $input = new Form\Control\Line(); + $input->readOnly = true; + $input->setApp($this->createApp()); + self::assertStringContainsString(' readonly="readonly"', $input->render()); + self::assertStringNotContainsString('disabled', $input->render()); + $input = new Form\Control\Line(); $input->disabled = true; $input->readOnly = true; $input->setApp($this->createApp()); self::assertStringContainsString(' disabled="disabled"', $input->render()); - self::assertStringContainsString(' readonly="readonly"', $input->render()); + self::assertStringNotContainsString('readonly', $input->render()); $input = new Form\Control\Hidden(); $input->disabled = true;