|
A form and its data can be in various states, as follows. <form_structure...> will respond to request to:
- mode=CREATE_FORM: present form for create of an item. Applicable top-level form & specific field defaults are presented.
- mode=UPDATE_FORM: present form for update of an item. No defaults are presented. Defaults should not be applied to empty fields, since for example user may have previously purposefully cleared a field of its default value.
The form STRUCTURE returned above will have mode="create_form" or "update_form" respectively.
Usually no server side validation of form contents should be done for a mode:CREATE_FORM form since empty form, even with defaults, may not be designed to fulfill logical requirements of form entry - this is up to the user. Form data in this mode is being presented to user (or external agent) for review before submission, and it would be premature to start presenting error messages (aside from an indication of required fields). Form's data is NOT being immediately entered in database, log or email. That's the work of forms in mode="create" or "update".
The <form> tag will take above structure, and produce an input field called "form_mode", which contains a "CREATE" or "UPDATE" value. Thus, after being presented with form for review and submission, the signal is included to attempt to advance the state of the form, i.e. a request (by user or external agent) to CREATE or UPDATE form contents, respectively.
The <form_structure...> tag will receive a request of mode=CREATE or mode=UPDATE as follows:
- Data is loaded into form structure, and no defaults are applied.
- Request is server-side validated.
- If validation fails,
- A mode="UPDATE" form structure becomes "UPDATE_FORM", to re-present form back to user. - A mode="CREATE" form structure becomes "CREATE_FORM", to re-present form.
- If validation succeeds, it is appropriate to apply <form_process...> tag.
- present for viewing: data retrieved only from database, no defaults apply.
<- ->
|