Class for forms. The form will take care for rendering the form, validating the submitted data and saving the data back to the item.
The form must be instanciated with an instance of an Form configuration and optional an SQLAlchemy mapped item.
If an SQLAlchemy mapped item is provided there are some basic validation is done based on the defintion in the database. Further the save method will save the values directly into the database.
If no item was provided than a dummy item will be created with the attributes of the configured fields in the form.
After submission this Dictionary will contain the validated data on successfull validation. Else this Dictionary will be empty
Returns a dictionary of all errors in the form. If page parameter is given, then only the errors for fields on the given page are returned. This dictionary will contain the errors if the validation fails. The key of the dictionary is the fieldname of the field. As a field can have more than one error the value is a list.
Page: | Dictionary with errors |
---|---|
Returns: | Dictionary with errors |
Returns a dictionary of all warnings in the form. If page parameter is given, then only the warnings for fields on the given page are returned. This dictionary will contain the warnings if the validation fails. The key of the dictionary is the fieldname of the field. As a field can have more than one warning the value is a list.
Page: | Name of the page |
---|---|
Returns: | Dictionary with warnings |
This is the initial data loaded from the given item. Used to render the readonly forms
Will save the validated data back into the item. In case of an SQLAlchemy mapped item the data will be stored into the database. :returns: Item with validated data.
The submitted data from the user. If validation fails, then this values are used to rerender the form.
Returns True if the validation succeeds else False. Validation of the data happens in three stages:
1. Prevalidation. Custom rules that are checked before any datatype checks on type conversations are made. 2. Basic type checks and type conversation. Type checks and type conversation is done based on the data type of the field and further constraint defined in the database if the form is instanciated with an SQLAlchemy mapped item. 3. Postvalidation. Custom rules that are checked after the type conversation was done.
All errors are stored in the errors dictionary through the process of validation. After the validation finished the values are stored in the data dictionary. In case there has been errors the dictionary will contain the origin submitted data.
Submitted: | Dictionary with submitted values. |
---|---|
Returns: | True or False |
Returns the parsed XML. This is a helper function to be used in connection with loading the configuration files. :xml: XML string to be parsed :returns: DOM of the parsed XML
Return the parsed XML form the given file. The function will load the file located in path and than returns the parsed content.