Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/views/select.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div>

<div>
<div x-init="$wire.set('value', {{ $initValueEncoded }})">
@if(!$searchable && $shouldShow)
@include($defaultView, [
'name' => $name,
Expand Down
5 changes: 4 additions & 1 deletion src/LivewireSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class LivewireSelect extends Component
public $placeholder;

public $value;
public $initValueEncoded;
public $optionsValues;

public $searchable;
Expand Down Expand Up @@ -75,6 +76,7 @@ public function mount($name,
$this->placeholder = $placeholder;

$this->value = $value;
$this->initValueEncoded = json_encode($value);

$this->searchable = $searchable;
$this->searchTerm = '';
Expand Down Expand Up @@ -119,7 +121,7 @@ public function options($searchTerm = null) : Collection

public function selectedOption($value)
{
return null;
return $value;
}

public function notifyValueChanged()
Expand Down Expand Up @@ -248,6 +250,7 @@ public function render()

return view($this->selectView)
->with([
'initValueEncoded' => $this->initValueEncoded,
'options' => $options,
'selectedOption' => $selectedOption ?? null,
'shouldShow' => $shouldShow,
Expand Down