-
Hello, I know that shoelace is supposed to intercept form submit events and append data to the FormData object as necessary. However, with an sl-dialog with child elements as seen below, the input does not get appended. Is there an easy way (that I am missing) to append a sl-dialog's child elements into FormData? Or do we have to do this manually?
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Is there a This seems to work as expected for me. https://codepen.io/paramagicdev/pen/YzoRKLa?editors=1000 If your markup doesn't allow a https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes |
Beta Was this translation helpful? Give feedback.
-
Thanks for your help! Yes, there is a <form name="frmEdit"><sl-dialog> <input id="txtTest" name="txtTest" value="1" type="hidden"></sl-dialog></form> Adding an explicit form attribute does seem to work <form name="frmEdit"><sl-dialog> <input id="txtTest" name="txtTest" value="1" type="hidden" form="frmEdit"></sl-dialog></form> Is there a way for the child elements to inherit the sl-dialog's parent form? |
Beta Was this translation helpful? Give feedback.
-
Yes, sorry for the typo on the form attachment (id/name). I found out what was causing the issue. Our pages are submitted with the Solutions are to submit using Thanks for your help! |
Beta Was this translation helpful? Give feedback.
Yes, sorry for the typo on the form attachment (id/name).
I found out what was causing the issue.
Our pages are submitted with the
form.submit()
method.form.submit()
does not trigger theSubmitEvent
which is the event Shoelace is listening to inject data intoFormData
.Solutions are to submit using
form.requestSubmit()
as that triggersSubmitEvent
. Or add the form attribute to the sl-dialog's child elements.Thanks for your help!