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

FormData & submitter[formaction] #381

Open
Lcfvs opened this issue Sep 15, 2023 · 6 comments
Open

FormData & submitter[formaction] #381

Lcfvs opened this issue Sep 15, 2023 · 6 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@Lcfvs
Copy link

Lcfvs commented Sep 15, 2023

Hi,

Is it possible to improve the behavior spec about the new FormData(form, submitter), to simply support something like this, please?

Using a submitter like:

<button formaction="..." formenctype="multipart/form-data" formmethod="post" type="submit" name="name" value="value">text</button>
new FormData(undefined, submitter) // actually, FormData (0)

Imho, if the button is a standalone submitter, there is no reason to be owned by a form to use it as a FormData submitter.

Any thoughts about that idea?

@annevk annevk transferred this issue from whatwg/html Sep 15, 2023
@annevk annevk added needs implementer interest Moving the issue forward requires implementers to express interest addition/proposal New features or enhancements labels Sep 15, 2023
@annevk
Copy link
Member

annevk commented Sep 15, 2023

It seems this would be rather magical as https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-the-form-data-set has an early return for an empty form. I guess we would have to pretend that the form contains the submitter in this case.

Perhaps you could elaborate on when this kind of thing has come up?

@Lcfvs
Copy link
Author

Lcfvs commented Sep 15, 2023

Sorry, my bad... Honestly, I just discovered that requirement: "Does nothing if there is no form owner."

Then a submitter can't be standalone, invalidating my question.

I'm self-asking why that required dependency but don't want to annoy you longer with that.

Thanks anyway.

@Lcfvs Lcfvs closed this as completed Sep 15, 2023
@annevk
Copy link
Member

annevk commented Sep 15, 2023

You're not annoying me! Just curious. I think the dependency is there because we get the fields from the form and then the submitter identifies the field that is the submitter. As I suggested above we could potentially invert some of that, but would need a compelling use case and some signal of web developer demand.

@Lcfvs
Copy link
Author

Lcfvs commented Sep 15, 2023

Ok, ok :)

In fact, actually, the idea behind to use them, as standalone, is to replace some anchors by some button[formaction]...

  • to avoid any risks related to the page preview feature of some browsers (AFAIK like planned for Chrome)
  • to have a "dynamic" variable sent to the server, based on the attributes (name & value), without to have something to manage it, even in GET/POST and/or in AJAX or not

And, really, I'm not convinced about the need of an extra form, trailing somewhere in the page to be able to send one of these buttons requests... moreover since it requires an id, "polluting" the globalThis for that... where these buttons can have anything we need to perform the requests, alone.

@annevk
Copy link
Member

annevk commented Sep 15, 2023

Alright, let's reopen this to see if more people hit this or if we find it to be a common library pattern or Stack Overflow question. Thanks!

@annevk annevk reopened this Sep 15, 2023
@Lcfvs
Copy link
Author

Lcfvs commented Sep 15, 2023

Thanks a lot for that shared curiosity :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

2 participants