Set the label of a select using $set
In my code I have
This code sets the value of my Select after a new item has been added using a
CreateOptionForm
. This succesfully sets the value of the Select. Does anyone know if it is possible to also set the label of the select somehow using the $set method?
Thanks8 Replies
$set
if for form data. You cannot set the labels. Use a closure ->label(fn () => set label from here)
But I think if the option exists inside your select options, the label should be selected automatically?OK I think you misunderstood mee.
It's not the label of the select but the label of the value. Maybe it is called optionLabel
So In my select I use CreateOptionForm to create a new product. Now when it returns it uses $set to update the value of the select. But how will it set the optionLabel?
Nvm I fixed it.
Hello @JJSanders How you resolved this? I'm having the same problem. Please help
Show some code and explain what's wrong
Solution
You mean the option label. So you want to use getOptionLabelUsing() ?
I ended up using getOptionLabelUsing
I have Driver, Vehicle and Contract fields
The form also has a field for changing the vehicle body number.
After this, I need to update the label in the "contract_id" field since its label contains vehicle body number
Hm. Not sure whether that's possible