Select Input populated via db query and setting default option?
Hi there,
I have a select input that is populated by a db query. I am trying to set the default value both at load time and also dynamically when a variable is set but whatever I try to implement this it doesn't work. I am using the "default" method to populate at mount time but no luck. I am not sure how the
For the dynamic update I am hoping that I can just reference the an object propery and have that update. Any ideas?
I have a select input that is populated by a db query. I am trying to set the default value both at load time and also dynamically when a variable is set but whatever I try to implement this it doesn't work. I am using the "default" method to populate at mount time but no luck. I am not sure how the
Select::make('Customer')
->options(Models\Customer::query()
->orderBy('Company Name')
->pluck('Company Name', 'Customer ID'))
->live()
->default(fn() => "1")
->afterStateUpdated(function ($state) {
$this->customer = Models\Customer::find($state);
}),'
For the dynamic update I am hoping that I can just reference the an object propery and have that update. Any ideas?