Skip to content

Commit 999dfeb

Browse files
authored
Merge pull request #1240 from livewire/josh/native-inputs
Add support for native form submissions
2 parents af0a963 + 8335b5b commit 999dfeb

File tree

4 files changed

+39
-9
lines changed

4 files changed

+39
-9
lines changed
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
@props([
2-
'name' => $attributes->whereStartsWith('wire:model')->first(),
2+
'name' => null,
33
])
44

55
@php
6+
// We only want to show the name attribute on the checkbox if it has been set
7+
// manually, but not if it has been set from the wire:model attribute...
8+
$showName = isset($name);
9+
10+
if (! isset($name)) {
11+
$name = $attributes->whereStartsWith('wire:model')->first();
12+
}
13+
614
$classes = Flux::classes()
715
->add('flex size-[1.125rem] rounded-[.3rem] mt-px outline-offset-2')
816
;
917
@endphp
1018

1119
<flux:with-inline-field :$attributes>
12-
<ui-checkbox {{ $attributes->class($classes) }} data-flux-control data-flux-checkbox>
20+
<ui-checkbox {{ $attributes->class($classes) }} @if($showName) name="{{ $name }}" @endif data-flux-control data-flux-checkbox>
1321
<flux:checkbox.indicator />
1422
</ui-checkbox>
1523
</flux:with-inline-field>
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
@props([
2-
'name' => $attributes->whereStartsWith('wire:model')->first(),
2+
'name' => null,
33
'variant' => null,
44
])
55

66
@php
7+
// We only want to show the name attribute it has been set manually
8+
// but not if it has been set from the `wire:model` attribute...
9+
$showName = isset($name);
10+
if (! isset($name)) {
11+
$name = $attributes->whereStartsWith('wire:model')->first();
12+
}
13+
714
$classes = Flux::classes()
815
// Adjust spacing between fields...
916
->add('*:data-flux-field:mb-3')
@@ -13,7 +20,7 @@
1320
@endphp
1421

1522
<flux:with-field :$attributes>
16-
<ui-radio-group {{ $attributes->class($classes) }} data-flux-radio-group>
23+
<ui-radio-group {{ $attributes->class($classes) }} @if($showName) name="{{ $name }}" @endif data-flux-radio-group>
1724
{{ $slot }}
1825
</ui-radio-group>
1926
</flux:with-field>
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
@props([
2-
'name' => $attributes->whereStartsWith('wire:model')->first(),
2+
'name' => null,
33
'variant' => null,
44
'size' => null,
55
])
66

77
@php
8+
// We only want to show the name attribute on the checkbox if it has been set
9+
// manually, but not if it has been set from the wire:model attribute...
10+
$showName = isset($name);
11+
12+
if (! isset($name)) {
13+
$name = $attributes->whereStartsWith('wire:model')->first();
14+
}
15+
816
$classes = Flux::classes()
917
->add('block flex p-1')
1018
->add('rounded-lg bg-zinc-800/5 dark:bg-white/10')
@@ -14,7 +22,7 @@
1422
@endphp
1523

1624
<flux:with-field :$attributes>
17-
<ui-radio-group {{ $attributes->class($classes) }} data-flux-radio-group-segmented>
25+
<ui-radio-group {{ $attributes->class($classes) }} @if($showName) name="{{ $name }}" @endif data-flux-radio-group-segmented>
1826
{{ $slot }}
1927
</ui-radio-group>
2028
</flux:with-field>

stubs/resources/views/flux/switch.blade.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
@props([
2-
'name' => $attributes->whereStartsWith('wire:model')->first(),
2+
'name' => null,
33
'align' => 'right',
44
])
55

66
@php
7+
// We only want to show the name attribute it has been set manually
8+
// but not if it has been set from the `wire:model` attribute...
9+
$showName = isset($name);
10+
if (! isset($name)) {
11+
$name = $attributes->whereStartsWith('wire:model')->first();
12+
}
13+
714
$classes = Flux::classes()
815
->add('group h-5 w-8 min-w-8 relative inline-flex items-center outline-offset-2')
916
->add('rounded-full')
@@ -29,13 +36,13 @@
2936

3037
@if ($align === 'left' || $align === 'start')
3138
<flux:with-inline-field :$attributes>
32-
<ui-switch {{ $attributes->class($classes) }} data-flux-control data-flux-switch>
39+
<ui-switch {{ $attributes->class($classes) }} @if($showName) name="{{ $name }}" @endif data-flux-control data-flux-switch>
3340
<span class="{{ \Illuminate\Support\Arr::toCssClasses($indicatorClasses) }}"></span>
3441
</ui-switch>
3542
</flux:with-inline-field>
3643
@else
3744
<flux:with-reversed-inline-field :$attributes>
38-
<ui-switch {{ $attributes->class($classes) }} data-flux-control data-flux-switch>
45+
<ui-switch {{ $attributes->class($classes) }} @if($showName) name="{{ $name }}" @endif data-flux-control data-flux-switch>
3946
<span class="{{ \Illuminate\Support\Arr::toCssClasses($indicatorClasses) }}"></span>
4047
</ui-switch>
4148
</flux:with-reversed-inline-field>

0 commit comments

Comments
 (0)