File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 1
1
<div >
2
2
3
- <div >
3
+ <div x-init = " $wire.set('value', {{ $initValueEncoded } } ) " >
4
4
@if (! $searchable && $shouldShow )
5
5
@if (! $multiple )
6
6
@include ($defaultView , [
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ class LivewireSelect extends Component
33
33
public $ placeholder ;
34
34
35
35
public $ value ;
36
+ public $ initValueEncoded ;
36
37
public $ optionsValues ;
37
38
38
39
public $ searchable ;
@@ -81,6 +82,7 @@ public function mount($name,
81
82
$ this ->placeholder = $ placeholder ;
82
83
83
84
$ this ->value = $ value ;
85
+ $ this ->initValueEncoded = json_encode ($ value );
84
86
85
87
$ this ->searchable = $ searchable ;
86
88
$ this ->searchTerm = '' ;
@@ -128,7 +130,7 @@ public function options($searchTerm = null) : Collection
128
130
129
131
public function selectedOption ($ value )
130
132
{
131
- return null ;
133
+ return $ value ;
132
134
}
133
135
134
136
public function notifyValueChanged ()
@@ -359,6 +361,7 @@ public function render()
359
361
360
362
return view ($ this ->selectView )
361
363
->with ([
364
+ 'initValueEncoded ' => $ this ->initValueEncoded ,
362
365
'options ' => $ options ,
363
366
'selectedOption ' => $ selectedOption ?? null ,
364
367
'shouldShow ' => $ shouldShow ,
You can’t perform that action at this time.
0 commit comments