The Molly Forms module implements an automated connection between forms and database
tables. The syntax for MAML forms tags is very similar to that of XHTML forms, making
implementation fairly straightforward. Forms can even be designed in a WYSIWYG editor,
then modified to work automatically in Molly. If you wish to bypass automatic forms,
simply use regular forms in the XHTML namespace.
The following tags have been implemented so far:
- <maml:form>
- <maml:input>
- type="text"
- type="submit"
- <maml:textarea>
- <maml:radiogroup>
- <maml:checkbox>
- <maml:file> (not complete)
(The remaining tags will be implemented soon, as much of the code already exists as
part of Molly I.)
<maml:form>
<maml:form table="test" response="/~rvullo/m2/test/list.maml" keyfield="age" schema="on" mode="output">
</maml:form>
table="test"
The table attribute indicates which table in the Molly database this
form is to access. (The Molly database itself is configured in system/core.php)
response="/~rvullo/m2/test/list.maml"
The response attribute tells Molly which
page to render after the form has been processed when the user clicks the submit button.
keyfield="age"
This tells Molly which field to use as the key when submitting
an update for (editing) a record.
schema="on"
When included, schema="on" will have Molly generate the SQL for creating
a table to support the form. (This is only a rough attempt at the SQL, and you will most
likely have to edit it to set field types and lengths to your liking.) The SQL is rendered
inside an XHTML comment in the generated source of the page when viewed with a browser.
mode="output"
Forms in Molly can be rendered as empty input forms, edit forms where
the data from a record is placed into the fields, or as output where the data from a record is
merely displayed. How the form is rendered can be controlled by the URL which calls the form
(using the format "form.maml?t_RenderAs=edit"). However, there are times when you do not want
a user to be able to edit the URL and change how a form is rendered. In those cases, you can
use the mode attribute to force the form to render in only one way.