Forms
A form is a document with fields where readers can enter data. There is no explicit markup for a form as a whole in Aneamal, but there are marks for form fields. All the form fields in an Aneamal file make up a single form automatically then.
Form fields
Textboxes
[_] …
- single-line textbox
[_]! …
- required single-line textbox
[_]->… …
- single-line textbox with input suggestions (combobox)
[=] …
- multi-line textbox
[=]! …
- required multi-line textbox
[=]->… …
- multi-line textbox with default text
Submission
Form submission is not done by the Aneamal Translator itself. A module is needed to submit and process forms. A submit button provided by a module could be integrated below the last form field in a webpage like this:
[x-submit]->mailto:post@example.org
The Aneamal Translator can abort submissions though. It aborts submissions, if at least one of a few requirements is not fulfilled:
- required options in the form must be selected,
- textboxes which require content must have content,
- data from the Aneamal Translator’s own hidden fields must be present,
- the authentication of the timestamp must succeed.
Modules can abort a submission, if they identify it as an attack or automatic spam.
For developers
For every Aneamal file that contains form fields, the Aneamal Translator adds a hidden HTML form element and hidden input elements at the end of the HTML code that corresponds to the Aneamal file.
<form id='_f1' method='post' enctype='multipart/form-data' hidden>
<input name='_form' type='hidden' value='_f1'>
<input name='_time' type='hidden' value='1672134525.765372'>
<input name='_taco' type='hidden' value='0ae9870bf89898849d0a55451b95ae9d957a371d4abfa30742b2631c4dad3709'>
<input type='submit' disabled>
</form>
When translated to HTML, all form fields from an Aneamal file get a form attribute whose value is identical to the id of this form element. This associates the form fields with the form. The form element’s method is always post
and the enctype always multipart/form-data
.
The meaning of the
elements is as follows:_form
- Contains the id of the form to associate submitted data with the correct form within the webpage.
_time
- UNIX timestamp with microsecond precision of when then Aneamal file was translated to HTML. This is either when the user accessed the webpage or when the webpage was stored in a cache.
_taco
- This is a timestamp authentication code used by the Aneamal Translator to check the authenticity of a submitted form’s timestamp.✻
Modules can access the values from these hidden input elements via PHP’s $_POST
variable, for example as $_POST['_time']
, when a form is submitted. Data entered into form fields, their labels and more is made available to modules via the form API.
The disabled submit input element prevents browsers from sending form data without the presence of a module that would handle the submission and provide a working submit button.
✻ The authentication of a valid timestamp can fail in the exceptional case that /aneamal/private/memory is manually erased after the posted form was generated, but the memory has since been created anew.