diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1c4426b..573d88d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +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 aside (@vjik)
## 3.7.0 September 18, 2024
diff --git a/src/Tag/Base/BooleanInputTag.php b/src/Tag/Base/BooleanInputTag.php
index fbc708f..51fc92a 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 aside with
+ * 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 902e86f..b35fb13 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(