...
You can also enforce data integrity by using validators.
Structure
All model entites used by system are defined in XML files. Every plugin has one directory model which contains xml files with definition of entities used by this plugin.
Name of defined entity must be unique within the plugin scope.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<model name="sampleModel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schema.qcadoo.org/model" xsi:schemaLocation="http://schema.qcadoo.org/model http://schema.qcadoo.org/model.xsd"> <fields> // HERE YOU PUT FIELD DEFINITIONS </fields> <hooks> // HERE YOU PUT HOOK DEFINITIONS </hooks> // HERE YOU PUT IDENTIFIER </model> |
...
- name - is a name of defined entity, it must be unique within the plugin scope
Structure of field definition
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<fieldType options> // HERE YOU PUT VALIDATORS </fieldType> |
...
- fieldType - is a type of field
- options - options of field
Field types
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<validatorType validatorOptions /> |
Where:
- validatorType - type of validator
...
Validator types
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<eventName class="className" method="methodName"<hookType hookOptions /> |
Where:
- eventName - name of event (see below)
- className - definies path and name to object with your custom method
- methodName - definies custom method name
Hook types
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
...
Role of entity identifier is to convert entity defined in model to a simple text (see expressions overview). It is used for example when showing operation messages. If not defined, system will use field 'number' of defined entityIf "expression" is givet it is used to evaluate identifier, otherwise "number" field will be taken.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<identifier expression="#number + ' - ' + #name"/> |
Where:
...
Examples
These examples definies three simple entities.
...