Custom Category Field

Joomla Asked by Grant G on August 18, 2020

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.


One Answer

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

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

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

Answered by Grant G on August 18, 2020

Add your own answers!

Related Questions

Disabling cache on specific part of page from above comment

2  Asked on September 14, 2020 by ruchika


Custom Category Field

1  Asked on August 18, 2020 by grant-g


How do I pass _JEXEC to a php file?

1  Asked on August 6, 2020 by firefighter


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP