Skip to content

Commit 24f88ad

Browse files
committed
- Enabled slot for label
Signed-off-by: Arushad Ahmed <dash-8x@hotmail.com>
1 parent d296653 commit 24f88ad

4 files changed

Lines changed: 43 additions & 5 deletions

File tree

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
@if($label || $blankLabel)
2-
<label {!! $attributes->merge(['class' => ($floating ? null : ($inline ? $inlineLabelClass : 'form-label'))]) !!}>{{ $label }}@if($required) <x-forms::label-required :framework="$framework" />@endif</label>
1+
@if($slot->isNotEmpty() || $label || $blankLabel)
2+
<label {!! $attributes->merge(['class' => ($floating ? null : ($inline ? $inlineLabelClass : 'form-label'))]) !!}>
3+
@if($slot->isNotEmpty())
4+
{{ $slot }}
5+
@else
6+
{{ $label }}
7+
@if($required) <x-forms::label-required :framework="$framework" />@endif
8+
@endif
9+
</label>
310
@endif
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
@if($label || $blankLabel)
22
<label {!! $attributes->merge([
33
'class' => (! $floating && $inline ? $inlineLabelClass : null)]) !!}>
4-
{{ $label }}
5-
@if($required)
6-
<x-forms::label-required :framework="$framework"></x-forms::label-required>
4+
@if($slot->isNotEmpty())
5+
{{ $slot }}
6+
@else
7+
{{ $label }}
8+
@if($required) <x-forms::label-required :framework="$framework" />@endif
79
@endif
810
</label>
911
@endif

‎tests/Feature/LabelTest.php‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,32 @@ public function setUp(): void
1414
Config::set('forms.inputs.required_text', 'forms::strings.required_text');
1515
}
1616

17+
public function test_it_can_generate_material_admin_label_with_a_slot()
18+
{
19+
$this->setFrameworkMaterialAdmin26();
20+
$this->registerTestRoute('label-slot');
21+
22+
$this->visit('/label-slot')
23+
->seeElementCount('label', 1)
24+
->within('label', function() {
25+
$this->seeElement('a')
26+
->seeInElement('a', 'some site');
27+
});
28+
}
29+
30+
public function test_it_can_generate_bootstrap_5_label_with_a_slot()
31+
{
32+
$this->setFrameworkBootstrap5();
33+
$this->registerTestRoute('label-slot');
34+
35+
$this->visit('/label-slot')
36+
->seeElementCount('label', 1)
37+
->within('label', function() {
38+
$this->seeElement('a')
39+
->seeInElement('a', 'some site');
40+
});
41+
}
42+
1743
public function test_it_can_generate_bootstrap_5_blank_form_group()
1844
{
1945
$this->setFrameworkBootstrap5();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<x-forms::label>
2+
Go to <a href="https://example.com">some site</a>.
3+
</x-forms::label>

0 commit comments

Comments
 (0)