Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input web components not sending a form #149

Open
tiapnn opened this issue Jun 17, 2020 · 3 comments
Open

input web components not sending a form #149

tiapnn opened this issue Jun 17, 2020 · 3 comments

Comments

@tiapnn
Copy link

tiapnn commented Jun 17, 2020

Hello there! Simple question for you seniors developers:

I seem to be unable to send a form using wiredjs web components! The form tag doesn't take the input of the input fields for some reason..

Here's a link to the webpage if you want to inspect.

Here's the code:

<form action="mailto:[email protected]" method="post" enctype="text/plain">
    <wired-input type="text" id="name" placeholder="Enter name" name="name"></wired-input>
    <wired-button type="submit">Submit form</wired-button>
  </form>

Cheers

@pshihn
Copy link
Contributor

pshihn commented Jun 17, 2020

It may not be supported at the moment out of the box. You may need to create the form data manually or perhaps add hidden fields in the form.

I will add some capability soon to make this happen automatically. Will need to do some research.

@Danny-Engelman
Copy link

If the element is in shadow DOM, then the creator of the element is responsible for providing values to a Form (or anything outside the element's shadowDOM)

You might also run into focus issues, which only Chredge can handle with non-standard delegateFocus for now: https://jsfiddle.net/CustomElementsExamples/9n6wtgj7/

@nileshtrivedi
Copy link

nileshtrivedi commented Jun 17, 2022

Shoelace solves this by handling the formdata event:

Every Shoelace component makes use of a shadow DOM to encapsulate markup, styles, and behavior. One caveat of this approach is that native <form> elements do not recognize form controls located inside a shadow root.

Shoelace solves this problem by using the formdata event, which is available in all modern browsers. This means, when a form is submitted, Shoelace form controls will automatically append their values to the FormData object that's used to submit the form. In most cases, things will "just work." However, if you're using a form serialization library, it might need to be adapted to recognize Shoelace form controls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants