Hi,
What are the best practices when submitting html forms in order to leverage namespaced keys?
For example, given the following form,
<form action="" method="get" class="form-example">
<input type="text" name="name" id="name" required>
<input type="email" name="email" id="email" required>
<input type="text" name="street id="street required>
<input type="submit" value="Subscribe!">
</form>
What is the best practice to get a map of clojure keys instead of just strings?
{
:person/name "Bla bla"
:person/email "bla@example.com"
:address/street "Planet Earth"
}
When sending json I believe you can process the form names before and do something to them ?!
But that feels clunky and you kind of need extra logic to do.
Also you would need to know the mapping beforehand or store the key in another attribute and switch the name -> value.
This can be done wither on the server or on the client but, again, feels clunky.
Is there a way to declare the keys and have the client / server use that instead of the name?
When submitting x-www-form-url-encoded I guess there is not much you can do.
I’ve checked the docs and there is a limited set of characters that are acceptable in the name:
Names can’t start with “:” also:
https://www.w3.org/TR/html401/interact/forms.html#control-name