Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit a32931e

Browse files
committed
Allow FormGroup component to accept a label id
1 parent 60706cb commit a32931e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

resources/views/components/form-group.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<x-dynamic-component :component="formComponentName('label')"
33
:for="$inputId"
44
class="{{ $inline && ! $isCheckboxGroup ? 'form-group__inline-label' : '' }}"
5+
:id="$labelId"
56
>
67
{{ $label }}
78
</x-dynamic-component>

src/Components/FormGroup.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class FormGroup extends BladeComponent
2020
/** @var string */
2121
public $helpText;
2222

23+
/** @var null|string */
24+
public $labelId;
25+
2326
public bool $inline;
2427
public bool $border;
2528
public bool $isCheckboxGroup;
@@ -32,7 +35,8 @@ public function __construct(
3235
bool $showErrors = true,
3336
string $helpText = null,
3437
bool $border = false,
35-
bool $isCheckboxGroup = false
38+
bool $isCheckboxGroup = false,
39+
string $labelId = null
3640
) {
3741
$this->name = $name;
3842
$this->inputId = $inputId ?? $name;
@@ -42,6 +46,7 @@ public function __construct(
4246
$this->helpText = $helpText;
4347
$this->border = $border;
4448
$this->isCheckboxGroup = $isCheckboxGroup;
49+
$this->labelId = $labelId;
4550
}
4651

4752
public function groupClass(): string

0 commit comments

Comments
 (0)