Hi, I have a search dropdown which allows a user (amongst other things) to pick a country from a dropdown list.
This aspect of the component is not dynamic, so I am selecting the data in a standard Laravel Controller, and then passing it to the component using:
@livewire('search-dropdown', ['countries' => $countries])
In SearchDropdown.php (Livewire component) I initalize the data using the following:
public function mount($countries) {
$this->countries = $countries;
}
This works successfully for the initial page load and the list of countries is displayed in a list in the view as expected. However, when the component refreshes, the list of countries appears blank.
The strangest thing is that I can see the data is being successfully sent from Livewire to the view on subsequent requests, but it doesn’t display in the view?
I’m really confused as it seems as though this should work, and the data is being correctly sent for all requests? For reference, I am displaying the data in the view using the following:
@foreach ($countries as $country)
@if(!empty($country->country_name)) <option>{{ $country->country_name }}</option> @endif
@endforeach
Any ideas? Any help appreciated!