diff --git a/resources/views/select.blade.php b/resources/views/select.blade.php index 18adc57..6d98915 100644 --- a/resources/views/select.blade.php +++ b/resources/views/select.blade.php @@ -1,6 +1,6 @@
-
+
@if(!$searchable && $shouldShow) @include($defaultView, [ 'name' => $name, diff --git a/src/LivewireSelect.php b/src/LivewireSelect.php index 3422f70..3b7ea45 100755 --- a/src/LivewireSelect.php +++ b/src/LivewireSelect.php @@ -32,6 +32,7 @@ class LivewireSelect extends Component public $placeholder; public $value; + public $initValueEncoded; public $optionsValues; public $searchable; @@ -75,6 +76,7 @@ public function mount($name, $this->placeholder = $placeholder; $this->value = $value; + $this->initValueEncoded = json_encode($value); $this->searchable = $searchable; $this->searchTerm = ''; @@ -119,7 +121,7 @@ public function options($searchTerm = null) : Collection public function selectedOption($value) { - return null; + return $value; } public function notifyValueChanged() @@ -248,6 +250,7 @@ public function render() return view($this->selectView) ->with([ + 'initValueEncoded' => $this->initValueEncoded, 'options' => $options, 'selectedOption' => $selectedOption ?? null, 'shouldShow' => $shouldShow,