1. Fabrik 3.5.2 is now available to download. Read the blog for highlights about this release.

    As always, please back up your site prior to updating and if possible test in a dev environment first.

    Also, our 3.5.1 package file was hacked, the effected dates were 1/15/2017 - 1/17/2017. If during those days you downloaded the 3.5.1 package file from the JED or our site download page, please re-install the package with a fresh copy or upgrade to Fabrik 3.5.2. Github downloads were not effected.

Validation Plugins

Oct 21, 2016
Validation Plugins
  • Every element can be validated during input to ensure that the data being entered meets defined criteria e.g. required or integer or in a particular format (e.g. phone numbers).

    Validation is performed using Validation Plugins, each of which is described separately.


    Validation conditions(top)


    Most validation plugin's have a condition field. This expects to receive a PHP statement which returns true or false.
    If it returns true then the validation is run
    If it returns false then the validation is ignored.

    Validations can use placeholders, so a valid condition statement is:

    PHP:

    return '{table___element}' === '1';
     
    For multiple conditions you can use the following format

    PHP:

    or condition
    return '{table___element}' == 2 || '{table___element}' == 1;
    and condition
    return '{table___element}' == 2 && '{table___element}' == 1;
     
    To only run a condition if the user has new/edit access for that element:

    PHP:

    return $this->elementModel->canUse();
     
    Since 21 Sept 2015, when the element which is being validated is in a repeat group, '{table___element}' will refer to the repeat group's data.

    Translating Validation Error Messages (top)


    Validation error messages are parsed through Joomla's JText function meaning you can provide translations for you error messages.


    • First edit an element and create a validation rule e.g. a not empty rule
    • Enter 'COM_FABRIK_CUSTOM_NOT_EMPTY' as the 'Error message'
    • Save the element
    • Go to Extensions -> language manager -> overrides
    • From the language drop down on the right hand side, select the language for which you want to provide a translation (e.g. select 'Englsh (United Kingdon - SIte)')
    • Press the 'new' button
    • Enter 'COM_FABRIK_CUSTOM_NOT_EMPTY' as the 'Language constant. This should match your validation's error message
    • Provide a translation in the 'Text' textarea, e.g 'Please enter something'
    • Save the entry

    Validation icons(top)

    Validation icons can be defined in the plugin settings "Options" (Extensions/Plugins)
    Insert your icon name, e.g. star or envelope