I've added a custom field to com_content, and everything has been working wonderfully. I'm now trying to add some server side validation, and after following all the tutorials and examples I've been able to find, specifically this one, it is failing because the rule isn't being found

The desired rule is almost identical to validating a Username, so I copyied/renamed that as my starting point. The files/paths DO exist, and load/save is working properly.

Is there additional information that I'm not providing or perhaps fresh eyes that will make me feel foolish when it's pointed out?

From the B/E, clicking on "Save" produces this error:

An error has occurred.

0 JForm::validateField() rule mycode missing.

Custom Field XML (Works as expected, except server validation)

<?xml version="1.0" encoding="utf-8"?>
<form addfieldpath="/administrator/components/com_mycomponent/models/rules">
    <fields name="params">
        <fieldset name="MyFields" label="My Info">
            <field name="my_code"
                type="text" size="15"
                label="My Code"


//jimport('joomla.form.formrule');   does not work with or without this
class JFormRuleMycode extends JFormRule
    public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null) {
        return true;

1 Answer 1


It seems that you actually have to specify what the path is for and put it in the right place, lol! The problem was in specifying a path for the fields instead of for the rules!

This correction fixed the problem:

    <fields name="params" addrulepath="/administrator/components/com_mycomponent/models/rules">

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.