Replies: 4 comments 3 replies
-
Please create a proper reproduction to get help |
Beta Was this translation helpful? Give feedback.
-
@segunadebayo I have the same question. The "question" is. On a form submit, we can get an I managed to get the value using the Please select the second or the third value on the select box then submit and you will see that always the first one is selected.! Thank you in advance! |
Beta Was this translation helpful? Give feedback.
-
@segunadebayo AND @pgswow Finally I found the reason the problem of not getting the correct value on
So, @segunadebayo what it the correct way of handling id on |
Beta Was this translation helpful? Give feedback.
-
Here is the solution you are looking for. "use client";
import { Select } from "@/components/ui/select";
export const FormUpdate = () => {
const items = ["React", "Solid", "Vue"];
return (
<form
onSubmit={(e) => {
e.preventDefault();
const formData = new FormData(e.target as HTMLFormElement);
for (const pair of formData.entries()) {
console.log(pair[0], pair[1]);
}
}}
>
<Select.Root items={items}>
<Select.Label>Framework</Select.Label>
<Select.HiddenSelect name="selectFieldName" />
<Select.Control>
<Select.Trigger>
<Select.ValueText placeholder="Select a Framework" />
<Select.Indicator>
<ChevronDownIcon />
</Select.Indicator>
</Select.Trigger>
<Select.ClearTrigger>Clear</Select.ClearTrigger>
</Select.Control>
<Select.Positioner>
<Select.Content>
<Select.ItemGroup>
<Select.ItemGroupLabel>Frameworks</Select.ItemGroupLabel>
{items.map((item) => (
<Select.Item key={item} item={item}>
<Select.ItemText>{item}</Select.ItemText>
<Select.ItemIndicator>✓</Select.ItemIndicator>
</Select.Item>
))}
</Select.ItemGroup>
</Select.Content>
</Select.Positioner>
</Select.Root>
<button type="submit">Submit</button>
</form>
);
}; |
Beta Was this translation helpful? Give feedback.
-
Hello!
When selecting a value and submitting the form, I only see the value from the input, how can I get the selected value from the select?
Beta Was this translation helpful? Give feedback.
All reactions