formsy-react
formsy-react copied to clipboard
Synchronized fields
Hi,
I would like to do something like this:
<input name="foo" />
<input name="foo" />
so that if user inputs something to first input, the second one fills the same automatically. What would be the best approach to do so in formsy controlled environment?
2 inputs can't have the same name
in HTML, therefore, formsy won't help you.
You can add other input & manage its value manually.
const MyApp = () => {
const [value, setValue] = useState('');
return (
<Form>
<Input
name="foo"
type="text"
value={value}
onChange={(e) => setValue(e.target.value)}
/>
<Input name="foo_replicate" type="hidden" value={value} />
</Form>
);
};
Going to close this as Felix answered it well. Re-open for further discussion.