SEM Labs

Handcrafted Pixels, Code & Title Tags

Collection

Elements

The XFL collection element validates groups of HTML fields. For example to ensure a certain number of checkboxes were selected from a group of checkboxes.

The XFL collection element can be used in two contexts. It can either contain a number of HTML form fields or it can be a child of a select element with the multiple attribute set.

Dissection of the XFL Collection Element

Syntax

Attributes

Attribute Value Description Required
type method name method to execute in the XFL_Collection class Yes
value text value to pass to the method No
select XPath query XPath query to retrive a value from data (post or population data) No
error text error to add to stack if method returns false No

Processing Information

XFL Collection elements will execute the method defined in the type attribute in the XFL_Collection class. Custom collection validators can be created by adding new methods to the XFL_Collection class.

Built-in Functions

XFL comes with the following collection validators built in.

required

The required validator will check if at least one field in a collection has a value, is checked or selected.

Example:

Outcome:

The collection will pass validation as one checkbox has been checked.

range

The range validator will check if a number of fields have a value, are checked or are selected as specified in a range.

Example:

Outcome:

The collection will pass validation as two checkboxes have been checked.