Using Joomla 3.9, although Custom Fields is now available, I am opting to do this in a plugin instead for reasons.

I have created a plugin to hook into the Category view in admin, so that I can add a custom field. This works in terms of, I enable the plugin, and the new tab and my custom field appear in the Edit Category view, but for some reason, the value I set does not save to the params in the database as expected.

Can anybody shed any light on this one?


<?xml version="1.0" encoding="UTF-8"?>
    <fields name="params">
        <fieldset name="category-icon" label="Icon">
            <field name="icon" type="text" default="icon-round" label="Category Icon" description="Enter the category icon" size="100" />


// no direct access
defined('_JEXEC') or die('Restricted access');

class plgContentCategoryExtension extends JPlugin

     * Load the language file on instantiation.
     * @var boolean
     * @since 3.1

    protected $autoloadLanguage = true;

    public function onContentPrepareForm($form, $data)

        $app = JFactory::getApplication();
        $option = $app->input->get('option');
        $view = $app->input->get('view');

        switch ($option) {

            case 'com_categories':

                switch ($view) {

                    case 'category':

                        if ($app->isAdmin()) {

                            JForm::addFormPath(__DIR__ . '/forms');

                            $form->loadFile('categoryextension', false);


                        return true;

            return true;

        return true;



I don't think there's anything I ought to do to hook into the save function, as I am using pretty much the same thing for custom fields on com_content for articles, plus the fact the tab and field actually show up in the admin make me believe this is working as expected, but alas, the field value does not save to the db params.


1 Answer 1

public function onContentPrepareForm(JForm $form, $data)
    if ($form->getName() !== 'com_categories.categorycom_content')

    JFormHelper::addFormPath(__DIR__ . '/forms');

    $form->loadFile('categoryextension', false);
  • Your answer has been automatically flagged by the system as "low-quality". Please avoid code-only answers. Please post with the intent to educate and empower thousands of future researchers and generously explaining your solution to people who may not understand what your script does or why it is a good technique. Commented Mar 20, 2020 at 11:22

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.