Skip to main content

Tutorial: Build your own custom field plugin - fields/owlimg.php


In the file fields/owlimg.php we will now create our field. Since we are using an existing field type and just customise it with our template the following code is sufficient:

 * @package     Joomla.Plugin
 * @subpackage  Fields.Owlimg
 * @copyright   Copyright (C) 2017 NAME. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt

defined('_JEXEC') or die;


class JFormFieldOwlimg extends JFormFieldFolderList
	public $type = 'Owlimg';

After the obligatory  <?php defined('_JEXEC') or die; we call the JForm Class with JFormHelper::loadFieldClass('folderlist');

You can find all the available JForm field types in the Joomla! documentation in this list:

After JFormField the name of our plugin follows beginning with an uppercase letter so JFormFieldOwlimg. With extends, we say that we want to extend an existing class. In this case JFormFieldFolderList.

Inside the class, we define the public type which is Owlimg.

If we need a "special input field", we could create or define it now inside this class. But here we are using an existing JForm field. To change some attributes of the existing listfield, we will dive into the main file owlimg.php in the root of our plugin. 

It's definitely time we get together!