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

Generating a module instance from PHP

0  Asked on September 5, 2021 by ffrewin


Embed custom JS app in Joomla MVC

0  Asked on September 5, 2021 by miasto


Error when updating Gantry from 4.1.20 to 4.1.32

1  Asked on September 5, 2021 by norberto-gomes


Change user permissions programmatically on the fly

1  Asked on September 5, 2021 by aheavyobject


Akeeba backup update broke the site

2  Asked on September 5, 2021 by hamlet-kraskian


Proper way for autoloading in Joomla 4

1  Asked on September 5, 2021 by webchun


Menu Specifically For Super Users

1  Asked on September 5, 2021


Joomla PHP does not match host PHP

2  Asked on February 18, 2021


Controller Joomla – Output Class construct for color css style

1  Asked on February 5, 2021 by andrea-suriani


Joomla custom component – router not find alias

1  Asked on January 21, 2021 by lecraver


Joomla 3 call model function inside controller

3  Asked on December 28, 2020 by wbdevlop


Product url problem after updating VirtueMart

1  Asked on December 23, 2020 by kiasaty


Display intro image inside mod_breadcrumbs

0  Asked on November 11, 2020 by geoplous


Ask a Question

Get help from others!

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