Elements
Elements
The XFL namespace is currently comprised of seven elements. There are four types of XFL elements: data manipulation elements (format, sanitise), definition elements (value), presentation manipulation elements (foreach), validation elements (collection, file, validate).
XFL elements execute methods in related classes. These classes can be edited to provide custom functionality. For example, the XFL validate element can be used to create a generic validator to validate a field to ensure it's value is a UK post code. To do this a method is added to the XFL_Validate class to undertake the necessary processing. This generic validator can then be used in any XFL file as such:
In this example, when a value is posted to the postcode field the parser will check if it validates as a UK post code. If not, the error attribute will be added to the error stack.
The XFL Elements
- Attributes – Adds attributes to fields
- Collection – Validates groups of fields
- File – Validates file uploads
- Foreach – Repeats blocks of an XFL file
- Format – Formats values the form is populated with
- If – Tests conditions
- Sanitise – Sanitises values posted to the form
- Validate – Validates individual fields
- Value – Assigns a value to a parent XFL node
- Valueof – Prints a value out