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

Commit b3dea52

Browse files
authored
Support for get the old value of a switch toggle without livewire (#41)
1 parent 029d44a commit b3dea52

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

resources/views/components/choice/switch-toggle.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ class="ml-3 switch-toggle-label form-label block text-sm font-medium leading-5 t
9292
@endif
9393

9494
@if ($name)
95-
<input type="hidden" name="{{ $name }}" x-bind:value="JSON.stringify(value)" />
95+
<input type="hidden" name="{{ $name }}" x-bind:value="value" />
9696
@endif
9797
</div>

src/Components/Choice/SwitchToggle.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function __construct(
3838
) {
3939
$this->id = $this->id ?? $this->name;
4040
$this->labelId = $this->id ?? Str::random(8);
41+
$this->value = $this->name ? old($this->name, $this->value) : $this->value;
4142
}
4243

4344
public function labelId(): string

0 commit comments

Comments
 (0)