Now I have situations to validate Module params in admin side of a module.

I know there is option with Filter in module params but its limited , I can't validate some patterns or custom conditions.

Is there any option available in Joomla to validate Module params on admin side ?

Thanks in Advance.


1 Answer 1


You can create a custom rule for validation. For example your module name is mod_mymodule:

  • Add addrulepath attribute to the fieldset in the .xml file:


This will be the path to the custom rule folder.

  • Add validate attribute to the field with the name of the rule file:


This will give us the file testint.php.

  • Create the rule file testint.php and put it to the path specified in the addrulepath attribute. So the full path will be:


Here is a simple validation rule class:

class JFormRuleTestint extends JFormRule
    public function test(&$element, $value, $group = null, &$input = null, &$form = null)
        return ((int)$value > 0 && (int)$value < 2);

it should extend JFormRule class and you will need only one method, called test. $value will contain the input from the field. Here we are testing it to be integer between 0 and 2.

  • To get this to work, I had to change it to addrulepath="administrator/modules/mod_mymodule", I had to add the line use Joomla\Registry\Registry; to the top of the PHP file, and I had to throw an error instead of returning false.
    – Flimm
    Jul 24, 2015 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.