use modal in form action? #458
-
Hi there, If I want to submit through the form's action and display a confirmation modal before submitting, do I have to hide the button and then use useRef like this: <button type="submit" style={{ display: 'none' }} id="hiddenSubmit"></button> and formRef.current.submit(); or there's some easier approaches? |
Beta Was this translation helpful? Give feedback.
Answered by
edmundhung
Feb 15, 2024
Replies: 1 comment 1 reply
-
You can put a submit button in the model and use the form attribute to associate it with the form, e.g. // In the component
const [form,fields] = useForm();
// In the dialog
<button form={form.id}>Confirm</button> If it is hard to pass the id down, you can always hard code it as long as it is unique. // In the component
const [form,fields] = useForm({
id: 'example',
});
// In the dialog
<button form="example">Confirm</button> |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
stimw
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can put a submit button in the model and use the form attribute to associate it with the form, e.g.
If it is hard to pass the id down, you can always hard code it as long as it is unique.