Reputation: 11
my issue with the ShadCn Combobox on Form is that onSelect (from CommandItem) cannot connect the value from Combobox with the form's field.
Is there a way to console.log values from CommandItem?
Here is the excerpt from my code:
<CommandList>
<CommandEmpty>Not found.</CommandEmpty>
<CommandGroup>
{serviceCategories.map((serviceCategory) => (
<CommandItem
value={serviceCategory.label}
key={serviceCategory.value}
onSelect={() => {
form.setValue(
"serviceCategory",
serviceCategory.value
);
}}
>
{serviceCategory.label}
</CommandItem>
))}
</CommandGroup>
</CommandList>
Thank you in advance.
I expect to obtain the value for "serviceCategory" based on the selected value from Combobox.
Upvotes: 1
Views: 319