Closed dcblogdev closed 2 years ago
In the component's mount method, ensure to assign the options first before assigning the model (selected value).
public function mount($id)
{
$product = Product::findOrFail($id);
$this->suppliers = Supply::get()->toArray(); // first, get list of options
$this->supplierId = $product->supplier_id; // second, assign the selected suppier
}
thank you, turns out to be a problem with how I was selecting the data I was using pluck changing how the data was loaded solved the issue in selecting an initial value
Supplier::select('id', 'name')->orderBy('name')->get()->toArray()
Thank you! this package is great.
How do you show a standard selected value?
I have this usage:
In my class I have mounted supplierId to an id I can see this if I render {{ $supplierId }} to the blade but the select does not pre-select the entry on load. The select menu remains blank until I manually select an item in the menu.