-
-
Notifications
You must be signed in to change notification settings - Fork 107
Unable to get select to work with relationships with Livewire #47
Comments
I have the same problem there is no solution, even temporary, before solving the bug? |
It is not a bug. Select options does not accept an array/collection of models, it should be array key/value. You either have to prepare the data in your controller or loop the model output. Slightly dirty but here is an example of how I did it.
Laravel form components will automatically set selected. If it was developed how you describe above then x-form-select would not know which field to use as the value and which to display in the select option. |
@Giovanni-Petrella @kurucu @andrecuellar I have put together a gist to help you with this. https://gist.github.com/mrl22/9693be99d155213400d6f3eb09657ac5 |
There is also the laravel helper Also, I've been having an issue with using Livewire in combination with component selects. I believe this is a Livewire issue though, as I have the same problem with my own simple select component. EDIT: I found the solution - make sure you are setting |
Following the docs, I'm trying to get Livewire to work with relationships and a multi-select.
Code is as follows:
Whilst the options are populated, the chosen ones are not selected when the form is shown, and any chosen ones are not saved when the form is submitted.
The text was updated successfully, but these errors were encountered: