How can I transform the value returned by a Controller? #1717
-
Is there a way to process the value returned by a Controller? For example, I have a component that must display two radio buttons, Yes and No, instead of a checkbox or switch, and I'd like to return a Boolean from that: return (
<Controller
as={
<RadioGroup
value={defaultValues[name]}
{...otherProps}
>
<FormControlLabel value="yes" control={<Radio/>} label="Yes"/>
<FormControlLabel value="no" control={<Radio/>} label="No"/>
</RadioGroup>
}
name={name}
control={control}
/>
); Or should this just be done in the submit handler? |
Beta Was this translation helpful? Give feedback.
Answered by
bluebill1049
May 28, 2020
Replies: 1 comment 3 replies
-
hey @dandv we are improving for now: take a look at this example: https://github.com/react-hook-form/react-hook-form/blob/master/examples/parseFormatInputValues.tsx |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
bluebill1049
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey @dandv we are improving
Controller
in the next release: #1711for now: take a look at this example:
https://github.com/react-hook-form/react-hook-form/blob/master/examples/parseFormatInputValues.tsx