I want to change some lines in this Joomla's 3.6.5 library file:


I searched many places to find out how to do this, but unfortunately there isn't a clear answer that explains step by step how can I override this library file in my template.

The only thing I've found is that it's possible to override library files, but it has its downsides (security threats after upgrades).

By editing this library file my purpose is change the messages shown after form validation errors.

Joomla only shows "invalid field: field label", but I want to change it and force it to clearly explains what is wrong about the field for user can understand which he/she input wrong.

After solving the above problem, I want to know how can I show each field's error message below it's input box, I don't like Joomla's default way that shows all the errors in a div above the form.

Please help me.

There's no website I haven't searched it for this problem to solve.


2 Answers 2


You can override the JForm class with your own version in one of two ways:

System Plugin

Via a System plugin that triggers onAfterInitialise():

* Registers core library overrides.
* @return   void
public function onAfterInitialise()
    // Override /libraries/joomla/form/form.php 
    JLoader::register('JForm', JPATH_LIBRARIES . '/core-overrides/joomla/form/form.php');

However, by the time onAfterInitialise() is called many core classes have already been initialized and so this method wont work. I don't know if JForm falls into this category or not. You may need to try it and find out. If it does fall into that category your only route is via a core hack...

Core Hack

First, obviously, core hacks are evil. But I've yet to find a working solution when the plugin method doesn't work (when the class has been initialized before onAfterInitialise() is called).

Modify /ROOT/index.php and/or /ROOT/administrator/index.php (depending on if you need this modification for back-end or front-end executions). Put this code:

require_once JPATH_LIBRARIES . '/core-overrides/coreOverrideAutoloader.php';
spl_autoload_register('CoreOverrideAutoloader::loader', true, true);

directly before:

require_once JPATH_BASE . '/includes/framework.php';

(both index.php files have that line)

Create /libraries/core-overrides/coreOverrideAutoloader.php:

class CoreOverrideAutoloader

    public static $requested = array();
    public static $filesLoaded = array();
    public static $filesNotLoaded = array();

    public static function loader($class)
        CoreOverrideAutoloader::$requested[] = $class;

        $filename = __DIR__ . '/' . strtolower($class) . '.php';

        if (!file_exists($file))
            CoreOverrideAutoloader::$filesNotLoaded[] = $file;
            return false;
        include $file;
        CoreOverrideAutoloader::$filesLoaded[] = $file;

Then create /libraries/core-overrides/jform.php

That'll hold your modified JForm class:

defined('JPATH_PLATFORM') or die;

use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;


class JForm

Creating any other library overrides is as simple as creating additional jclassname.php files in that same folder.

WARNING Regardless of which solution works for you remember that both create a maintenance issue. With the core hack solution Joomla updates may undo the core hack so you'll need to check your index.php files after every Joomla update (yuck). Secondly, with either solution there is the possibility that the original JForm may be updated with a Joomla update. That wont affect your modified version but you still need to check for what was changed in the core JForm and possibly update your modified version with those same changes. Last thing you want is site errors or security vulnerabilities because your slightly modified version of JForm is multiple version behind the core JForm.


Unfortunately, you can't override the default validation messages of Joomla. However, if you want to change the javascript messages you can hack in the media/system/js/validate.js file. (Don't do this until you really want it).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy