starfederation / datastar

The hypermedia framework.
https://data-star.dev
MIT License
758 stars 46 forks source link

Figure out forms #293

Open bencroker opened 1 week ago

bencroker commented 1 week ago

Figure out working with forms in Datastar (aka Delboy’s Magnum Opus).

For reference: https://github.com/starfederation/datastar/discussions/82, https://github.com/starfederation/datastar/discussions/136

Superpat commented 1 week ago

First of all, do we want to figure out forms before v1.0 ?

Second of all, how much magic do we want ?

I'm sure there's other stuff, but that's the questions I had.

dkotik commented 1 week ago

First of all, do we want to figure out forms before v1.0?

Absolutely!

Should it be a nested signal under the form's namespace?

Certainly!

I wondered if there is an ability to scope $post body here: https://github.com/starfederation/datastar/discussions/302 I think this issue is entirely related. Right now there is too much magic. JSON encoding a step away from hypermedia. Should it perhaps be an extension, with form data being the default? Seem sensible to me.

Also, using <input> and such without <form> tag is technically incorrectly formed HTML - it gets picked on by linters. I suggest that data submission should be handled via forms, not the global store of everything.

Superpat commented 1 week ago

First of all, do we want to figure out forms before v1.0?

Absolutely!

I ask the question because it could very well be a separate plugin that does not affect the datastar core, so released on a separate occasion. Though stuff like validation of data-bind would occasion changes to other plugins.

I wondered if there is an ability to scope $post body here: #302 I think this issue is entirely related. Right now there is too much magic. JSON encoding a step away from hypermedia. Should it perhaps be an extension, with form data being the default? Seem sensible to me.

Also, using <input> and such without <form> tag is technically incorrectly formed HTML - it gets picked on by linters. I suggest that data submission should be handled via forms, not the global store of everything.

I highly doubt @delaneyj is going to want to change the default format of post requests data in datastar, but the ability to use a different encoding for the data could be very useful. I know I've had a datastar project that used an external api that only accepted formdata encoded images and having to reparse the file as formdata was annoying.