Custom (app specific) field types

Applications can add their own custom field types, which should be derived from BaseField or one of its descendants. A very simple single item custom field type could look like this:

Build the field type

namespace myVendorName\myModule;
use OPNsense\Base\FieldTypes\BaseField;
use Phalcon\Validation\Validator\Regex;

class SimpleCustomField extends BaseField
    protected $internalIsContainer = false;
    protected $internalValidationMessage = "standard error";
    public function getValidators()
        $validators = parent::getValidators();
        $reservedwords = array('all', 'pass', 'block', 'out');
        $validators[] = new ExclusionIn(array(
            'message' => 'can not use a reserved word',
            'domain' => $reservedwords));
    return $validators;

This example extends the standard validations with a list of reserved words, in which case it would yield can not use a reserved word if one of the reserved words are provided.


This file should be placed in the subdirectory FieldTypes of the model itself.


Use BaseListField as simple template for list type items.

Use in model

The validation can be used as any standard type, when prefixed with . the model knows it concerns a local field.

        My first application
            <name type=".\SimpleCustomField">


Inspect the basic field types for inspiration, a concrete example of a custom field type can be found in the firewall section