From b2bc0cdfc03c6713470804c750e93cbe7b36da2c Mon Sep 17 00:00:00 2001 From: CyberVitexus Date: Thu, 4 Jun 2026 00:18:40 +0200 Subject: [PATCH 1/2] fix: correct Bootstrap 5 navbar flex classes and include rightContent in collapse Three bugs in Navbar.php: - leftContent had ms-auto (margin-left: auto) which mis-aligned nav items right; changed to no auto-margin so items stay left-aligned naturally - rightContent had ml-auto (Bootstrap 4 class, removed in BS5); updated to ms-auto so right-placed items are pushed to the far right - navBarCollapse() only wrapped leftContent; rightContent was never rendered; both ULs are now included so addMenuItem(..., 'right') items actually appear Co-Authored-By: Claude Sonnet 4.6 --- src/Ease/TWB5/Navbar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Ease/TWB5/Navbar.php b/src/Ease/TWB5/Navbar.php index 1896ba1..3448520 100644 --- a/src/Ease/TWB5/Navbar.php +++ b/src/Ease/TWB5/Navbar.php @@ -67,8 +67,8 @@ public function __construct($brand = null, $name = 'navbar', $properties = []) parent::__construct(null, $properties); Part::twBootstrapize(); - $this->leftContent = new UlTag(null, ['class' => 'navbar-nav ms-auto flex-nowrap navbar-expand mb-2 mb-lg-0', 'style' => '--bs-scroll-height: 100px;']); - $this->rightContent = new UlTag(null, ['class' => 'navbar-nav ml-auto']); // TODO + $this->leftContent = new UlTag(null, ['class' => 'navbar-nav flex-nowrap mb-2 mb-lg-0', 'style' => '--bs-scroll-height: 100px;']); + $this->rightContent = new UlTag(null, ['class' => 'navbar-nav ms-auto flex-nowrap mb-2 mb-lg-0']); $this->containerFluid = $this->addItem(new \Ease\Html\DivTag([new ATag($this->mainpage, $brand, ['class' => 'navbar-brand']), $this->navBarToggler()], ['class' => 'container-fluid'])); } From a3f684967652dbf8dd4d3c652ece5f5b0ad2d31d Mon Sep 17 00:00:00 2001 From: CyberVitexus Date: Tue, 9 Jun 2026 09:11:27 +0200 Subject: [PATCH 2/2] Port FormGroup to Bootstrap 5 markup and flexible signature Replace the stale Bootstrap 4 carry-over with a proper Bootstrap 5 widget: .mb-3 wrapper, .form-label label and .form-text helper text. Restore the flexible ($label, $content, $placeholder, $helptext, $addTagClass) signature used across callers. The previous strict 3-arg, Input-typed constructor threw on label-only/no-arg calls, non-Input content (ATag, SelectTag) and the 4-arg helptext form, and referenced a non-existent Ease\TWB5\DivTag. Co-Authored-By: Claude Opus 4.8 --- src/Ease/TWB5/FormGroup.php | 79 +++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 12 deletions(-) diff --git a/src/Ease/TWB5/FormGroup.php b/src/Ease/TWB5/FormGroup.php index 5d32c15..e382e3d 100644 --- a/src/Ease/TWB5/FormGroup.php +++ b/src/Ease/TWB5/FormGroup.php @@ -16,22 +16,77 @@ namespace Ease\TWB5; /** - * Description of FormGroup. + * Bootstrap 5 form group. * - * @author vitex + * Wraps a label, a form control and optional helper text using Bootstrap 5 + * markup (.mb-3 wrapper, .form-label label, .form-text helper). Replaces the + * Bootstrap 4 .form-group based widget. + * + * @author Vítězslav Dvořák */ class FormGroup extends \Ease\Html\DivTag { - public function __construct($label, \Ease\Html\Input $input, $desc = '') - { - $id = $input->setTagID(); - parent::__construct(new \Ease\Html\LabelTag($id, $label)); - $input->addTagClass('form-control'); - $input->setTagProperties(['aria-describedby' => 'desc'.$id]); - $this->addItem($input); - - if ($desc) { - $this->addItem(new DivTag($desc, ['id' => 'desc'.$id, 'class' => 'form-text'])); + /** + * Bootstrap 5 form group. + * + * @param mixed $label field label (string, Tag or array) + * @param mixed $content form control widget (or any renderable content) + * @param string $placeholder placeholder text put into the control + * @param mixed $helptext helper text rendered below the control + * @param string $addTagClass CSS class applied to the control (Bootstrap: form-control) + */ + public function __construct( + $label = null, + $content = null, + $placeholder = null, + $helptext = null, + $addTagClass = 'form-control', + ) { + parent::__construct(null, ['class' => 'mb-3']); + + // Resolve an id used to bind the label to the control. + $id = null; + + if (\is_object($content) && method_exists($content, 'getTagID')) { + $id = $content->getTagID(); + } + + if (empty($id) && \is_string($label) && $label !== '') { + $id = \Ease\Functions::lettersOnly($label); + } + + if (empty($id)) { + $id = 'formgroup_'.\Ease\Functions::randomString(); + } + + if ($label !== null && $label !== '') { + $this->addItem(new \Ease\Html\LabelTag((string) $id, $label, ['class' => 'form-label'])); + } + + if (\is_object($content)) { + if ($addTagClass && method_exists($content, 'addTagClass')) { + $content->addTagClass($addTagClass); + } + + if ($placeholder && method_exists($content, 'setTagProperties')) { + $content->setTagProperties(['placeholder' => $placeholder]); + } + + if (method_exists($content, 'setTagID')) { + $content->setTagID((string) $id); + } + + if ($helptext && method_exists($content, 'setTagProperties')) { + $content->setTagProperties(['aria-describedby' => 'desc'.$id]); + } + + $this->addItem($content); + } elseif ($content !== null) { + $this->addItem($content); + } + + if ($helptext) { + $this->addItem(new \Ease\Html\DivTag($helptext, ['id' => 'desc'.$id, 'class' => 'form-text'])); } } }