From 839ba483d70952c395412686ee265cbfd17d25a6 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 22 Oct 2024 17:33:23 +0300 Subject: [PATCH 1/6] Add optional `wrap` parameter to `BooleanInputTag::label()` --- CHANGELOG.md | 1 + src/Tag/Base/BooleanInputTag.php | 10 ++++++++-- tests/Tag/Base/BooleanInputTagTest.php | 10 ++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c4426b3..7124a33d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Enh #220: Add `non-empty-string` psalm type of `Html::generateId()` method result (@vjik) - Enh #220: Add `non-empty-string|null` psalm type of `Tag::id()` method parameter (@vjik) - Enh #222: Bump minimal PHP version to 8.1 and refactor (@vjik) +- New #224: Add optional `wrap` parameter to `BooleanInputTag::label()` method that allow to set label placement (@vjik) ## 3.7.0 September 18, 2024 diff --git a/src/Tag/Base/BooleanInputTag.php b/src/Tag/Base/BooleanInputTag.php index fbc708f6..882fb6b9 100644 --- a/src/Tag/Base/BooleanInputTag.php +++ b/src/Tag/Base/BooleanInputTag.php @@ -36,12 +36,18 @@ final public function checked(bool $checked = true): static * * @param string|null $label Input label. * @param array $attributes Name-value set of label attributes. + * @param bool $wrap Whether to wrap input with label tag. If set to `false`, label will be rendered side on side + * input. */ - final public function label(?string $label, array $attributes = []): static - { + final public function label( + ?string $label, + array $attributes = [], + bool $wrap = true, + ): static { $new = clone $this; $new->label = $label; $new->labelAttributes = $attributes; + $new->labelWrap = $wrap; return $new; } diff --git a/tests/Tag/Base/BooleanInputTagTest.php b/tests/Tag/Base/BooleanInputTagTest.php index 902e86f3..b35fb133 100644 --- a/tests/Tag/Base/BooleanInputTagTest.php +++ b/tests/Tag/Base/BooleanInputTagTest.php @@ -61,6 +61,16 @@ public function testLabel(string $expected, ?string $label, array $attributes): ); } + public function testLabelNoWrap(): void + { + $this->assertSame( + ' ', + (string) TestBooleanInputTag::tag() + ->id('ID') + ->label('Voronezh', wrap: false), + ); + } + public function testLabelWithId(): void { $this->assertSame( From e83f4a7084d8ded14719d5e2dd15494c594ba728 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 22 Oct 2024 21:03:42 +0300 Subject: [PATCH 2/6] Update CHANGELOG.md Co-authored-by: Alexander Makarov --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7124a33d..79dbbdc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - Enh #220: Add `non-empty-string` psalm type of `Html::generateId()` method result (@vjik) - Enh #220: Add `non-empty-string|null` psalm type of `Tag::id()` method parameter (@vjik) - Enh #222: Bump minimal PHP version to 8.1 and refactor (@vjik) -- New #224: Add optional `wrap` parameter to `BooleanInputTag::label()` method that allow to set label placement (@vjik) +- New #224: Add optional `wrap` parameter to `BooleanInputTag::label()` method that allows setting label placement (@vjik) ## 3.7.0 September 18, 2024 From 923fead7f405f6e513f96662e132ebcf1f84cd81 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 23 Oct 2024 17:04:31 +0300 Subject: [PATCH 3/6] Update CHANGELOG.md Co-authored-by: Alexey Rogachev --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79dbbdc7..e32080e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - Enh #220: Add `non-empty-string` psalm type of `Html::generateId()` method result (@vjik) - Enh #220: Add `non-empty-string|null` psalm type of `Tag::id()` method parameter (@vjik) - Enh #222: Bump minimal PHP version to 8.1 and refactor (@vjik) -- New #224: Add optional `wrap` parameter to `BooleanInputTag::label()` method that allows setting label placement (@vjik) +- New #224: Add optional `wrap` parameter to `BooleanInputTag::label()` method that controls whether to wrap input tag with label tag or place them side by side. (@vjik) ## 3.7.0 September 18, 2024 From a8085440d4d9dd95612b06e0326d7ec8b8e28ef6 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 23 Oct 2024 17:04:53 +0300 Subject: [PATCH 4/6] Update src/Tag/Base/BooleanInputTag.php Co-authored-by: Alexey Rogachev --- src/Tag/Base/BooleanInputTag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tag/Base/BooleanInputTag.php b/src/Tag/Base/BooleanInputTag.php index 882fb6b9..41b9039b 100644 --- a/src/Tag/Base/BooleanInputTag.php +++ b/src/Tag/Base/BooleanInputTag.php @@ -37,7 +37,7 @@ final public function checked(bool $checked = true): static * @param string|null $label Input label. * @param array $attributes Name-value set of label attributes. * @param bool $wrap Whether to wrap input with label tag. If set to `false`, label will be rendered side on side - * input. + * with input. */ final public function label( ?string $label, From 4d4d1a38cd8e228dac61a90b5fda3487e98c473d Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 23 Oct 2024 17:05:01 +0300 Subject: [PATCH 5/6] Update src/Tag/Base/BooleanInputTag.php Co-authored-by: Alexey Rogachev --- src/Tag/Base/BooleanInputTag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tag/Base/BooleanInputTag.php b/src/Tag/Base/BooleanInputTag.php index 41b9039b..e8cf719c 100644 --- a/src/Tag/Base/BooleanInputTag.php +++ b/src/Tag/Base/BooleanInputTag.php @@ -36,7 +36,7 @@ final public function checked(bool $checked = true): static * * @param string|null $label Input label. * @param array $attributes Name-value set of label attributes. - * @param bool $wrap Whether to wrap input with label tag. If set to `false`, label will be rendered side on side + * @param bool $wrap Whether to wrap input with label tag. If set to `false`, label will be rendered side by side * with input. */ final public function label( From 9f561986282ed5021dfb306c81613d650bfc8930 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 23 Oct 2024 17:07:40 +0300 Subject: [PATCH 6/6] fix --- CHANGELOG.md | 3 ++- src/Tag/Base/BooleanInputTag.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e32080e1..573d88d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ - Enh #220: Add `non-empty-string` psalm type of `Html::generateId()` method result (@vjik) - Enh #220: Add `non-empty-string|null` psalm type of `Tag::id()` method parameter (@vjik) - Enh #222: Bump minimal PHP version to 8.1 and refactor (@vjik) -- New #224: Add optional `wrap` parameter to `BooleanInputTag::label()` method that controls whether to wrap input tag with label tag or place them side by side. (@vjik) +- New #224: Add optional `wrap` parameter to `BooleanInputTag::label()` method that controls whether to wrap input tag + with label tag or place them aside (@vjik) ## 3.7.0 September 18, 2024 diff --git a/src/Tag/Base/BooleanInputTag.php b/src/Tag/Base/BooleanInputTag.php index e8cf719c..51fc92a6 100644 --- a/src/Tag/Base/BooleanInputTag.php +++ b/src/Tag/Base/BooleanInputTag.php @@ -36,8 +36,8 @@ final public function checked(bool $checked = true): static * * @param string|null $label Input label. * @param array $attributes Name-value set of label attributes. - * @param bool $wrap Whether to wrap input with label tag. If set to `false`, label will be rendered side by side - * with input. + * @param bool $wrap Whether to wrap input with label tag. If set to `false`, label will be rendered aside with + * input. */ final public function label( ?string $label,