lustre-labs / lustre

A Gleam web framework for building HTML templates, single page applications, and real-time server components.
https://hexdocs.pm/lustre
MIT License
949 stars 65 forks source link

feat: add form-related attributes #50

Closed brattonross closed 6 months ago

brattonross commented 6 months ago

Adds various attributes related to form submission, based on the attributes listed by the MDN docs.

Note that the target attribute was already defined in the "links and areas" section of attribute.gleam.

hayleigh-dot-dev commented 6 months ago

Awesome thanks! What is the purpose of the attributes prefixed with form? eg formnovalidate vs novalidate

brattonross commented 6 months ago

The attributes prefixed with form can be placed on <button>, <input type="submit">, or <input type="image"> elements to override the non-prefixed attributes on <form>

e.g. if you have <form method="post">, and then put a <button formmethod="get"> inside it, clicking that button will submit the form with the GET method

hayleigh-dot-dev commented 6 months ago

Ah that's very cool! Do you think we should name them form_method instead? Not sure I have an opinion on keeping naming parity with the attribute precisely.

brattonross commented 6 months ago

If you're not worried about keeping parity with HTML, then I agree that snake casing will read easier :) I'll update my PR

hayleigh-dot-dev commented 6 months ago

Looks great, thank you very much!