From 257bf5ff392a214b5b86abd21f13bb1fd7401a80 Mon Sep 17 00:00:00 2001 From: Dennis Riehle Date: Tue, 5 Apr 2022 12:13:39 +0200 Subject: [PATCH 1/2] fix label placement for MultiCheckbox (and Radio) --- .github/workflows/continuous-integration.yml | 1 + src/TwbsHelper/Form/View/Helper/FormRow.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 3476a0a71..af27cea62 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - 4.x pull_request: paths-ignore: - "**.md" diff --git a/src/TwbsHelper/Form/View/Helper/FormRow.php b/src/TwbsHelper/Form/View/Helper/FormRow.php index c7de53601..2b0a15ff2 100644 --- a/src/TwbsHelper/Form/View/Helper/FormRow.php +++ b/src/TwbsHelper/Form/View/Helper/FormRow.php @@ -85,8 +85,6 @@ public function render(\Laminas\Form\ElementInterface $element, ?string $labelPo switch (true) { // Form group disabled case $element->getOption('form_group') === false: - // Radio elements - case $elementType === 'radio': // All "button" elements in inline form case in_array($elementType, ['submit', 'button', 'reset'], true) && $layout === \TwbsHelper\Form\View\Helper\Form::LAYOUT_INLINE: @@ -305,9 +303,12 @@ protected function getDefaultLabelPosition(\Laminas\Form\ElementInterface $eleme } } + if ($element instanceof \Laminas\Form\Element\MultiCheckbox) { + return self::LABEL_PREPEND; + } + switch ($element->getAttribute('type')) { case 'checkbox': - case 'radio': return self::LABEL_APPEND; case 'file': if ($element->getOption('custom')) { From c6d311e5cd52ac34977f1e3b488901de3343fc3c Mon Sep 17 00:00:00 2001 From: Dennis Riehle Date: Tue, 5 Apr 2022 12:52:35 +0200 Subject: [PATCH 2/2] updated snapshots and documentation --- .../Tests/Components/Forms/CustomForms.php | 3 ++ .../Forms/Layout/FormGrid/HorizontalForm.php | 1 - .../Layout/Form_grid/Horizontal_form__1.html | 24 +++++---- .../Inline_forms/Horizontal_form__1.html | 24 +++++---- website/docs/usage/components/forms.mdx | 53 ++++++++++--------- 5 files changed, 58 insertions(+), 47 deletions(-) diff --git a/tests/TestSuite/Documentation/Tests/Components/Forms/CustomForms.php b/tests/TestSuite/Documentation/Tests/Components/Forms/CustomForms.php index d69265aab..87f74776a 100644 --- a/tests/TestSuite/Documentation/Tests/Components/Forms/CustomForms.php +++ b/tests/TestSuite/Documentation/Tests/Components/Forms/CustomForms.php @@ -40,6 +40,7 @@ 'name' => 'customRadio', 'type' => 'radio', 'options' => [ + 'form_group' => false, 'custom' => true, 'value_options' => [ [ @@ -68,6 +69,7 @@ 'type' => 'radio', 'options' => [ 'layout' => \TwbsHelper\Form\View\Helper\Form::LAYOUT_INLINE, + 'form_group' => false, 'custom' => true, 'value_options' => [ [ @@ -110,6 +112,7 @@ 'name' => 'radioDisabled', 'type' => 'radio', 'options' => [ + 'form_group' => false, 'custom' => true, 'value_options' => [ [ diff --git a/tests/TestSuite/Documentation/Tests/Components/Forms/Layout/FormGrid/HorizontalForm.php b/tests/TestSuite/Documentation/Tests/Components/Forms/Layout/FormGrid/HorizontalForm.php index b046b65dc..ada04ecde 100644 --- a/tests/TestSuite/Documentation/Tests/Components/Forms/Layout/FormGrid/HorizontalForm.php +++ b/tests/TestSuite/Documentation/Tests/Components/Forms/Layout/FormGrid/HorizontalForm.php @@ -53,7 +53,6 @@ 'type' => 'radio', 'name' => 'gridRadios', 'options' => [ - 'column' => 'sm-10', 'value_options' => [ [ 'label' => 'First radio', diff --git a/tests/TestSuite/Documentation/__snapshots__/Components/Forms/Layout/Form_grid/Horizontal_form__1.html b/tests/TestSuite/Documentation/__snapshots__/Components/Forms/Layout/Form_grid/Horizontal_form__1.html index 3fe4df1b1..d579a6237 100644 --- a/tests/TestSuite/Documentation/__snapshots__/Components/Forms/Layout/Form_grid/Horizontal_form__1.html +++ b/tests/TestSuite/Documentation/__snapshots__/Components/Forms/Layout/Form_grid/Horizontal_form__1.html @@ -16,17 +16,19 @@
Radios
-
- - -
-
- - -
-
- - +
+
+ + +
+
+ + +
+
+ + +
diff --git a/tests/TestSuite/Documentation/__snapshots__/Components/Forms/Layout/Inline_forms/Horizontal_form__1.html b/tests/TestSuite/Documentation/__snapshots__/Components/Forms/Layout/Inline_forms/Horizontal_form__1.html index 3fe4df1b1..d579a6237 100644 --- a/tests/TestSuite/Documentation/__snapshots__/Components/Forms/Layout/Inline_forms/Horizontal_form__1.html +++ b/tests/TestSuite/Documentation/__snapshots__/Components/Forms/Layout/Inline_forms/Horizontal_form__1.html @@ -16,17 +16,19 @@
Radios
-
- - -
-
- - -
-
- - +
+
+ + +
+
+ + +
+
+ + +
diff --git a/website/docs/usage/components/forms.mdx b/website/docs/usage/components/forms.mdx index 4b2374ee9..4f01e0f77 100644 --- a/website/docs/usage/components/forms.mdx +++ b/website/docs/usage/components/forms.mdx @@ -1092,17 +1092,19 @@ echo $this->form(
Radios
-
- - -
-
- - -
-
- - +
+
+ + +
+
+ + +
+
+ + +
@@ -1189,7 +1191,6 @@ echo $this->form( 'type' => 'radio', 'name' => 'gridRadios', 'options' => [ - 'column' => 'sm-10', 'value_options' => [ [ 'label' => 'First radio', @@ -2010,17 +2011,19 @@ echo $this->form(
Radios
-
- - -
-
- - -
-
- - +
+
+ + +
+
+ + +
+
+ + +
@@ -2107,7 +2110,6 @@ echo $this->form( 'type' => 'radio', 'name' => 'gridRadios', 'options' => [ - 'column' => 'sm-10', 'value_options' => [ [ 'label' => 'First radio', @@ -3137,6 +3139,7 @@ echo $this->formRow( 'name' => 'customRadio', 'type' => 'radio', 'options' => [ + 'form_group' => false, 'custom' => true, 'value_options' => [ [ @@ -3191,6 +3194,7 @@ echo $this->formRow( 'type' => 'radio', 'options' => [ 'layout' => \TwbsHelper\Form\View\Helper\Form::LAYOUT_INLINE, + 'form_group' => false, 'custom' => true, 'value_options' => [ [ @@ -3263,6 +3267,7 @@ echo $this->formRow( 'name' => 'radioDisabled', 'type' => 'radio', 'options' => [ + 'form_group' => false, 'custom' => true, 'value_options' => [ [