Skip to content

Instantly share code, notes, and snippets.

@betweenbrain
Last active March 11, 2023 03:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save betweenbrain/adc20926781182c502ab4c47bdacd7f5 to your computer and use it in GitHub Desktop.
Save betweenbrain/adc20926781182c502ab4c47bdacd7f5 to your computer and use it in GitHub Desktop.
Developing a custom Joomla custom field plugin

Anatomy of a custom form field

fields
  |
  -- fieldName.php
language
  |
  -- en-GB
    |
    -- en-GB.plg_fields_fieldName.ini
    -- en-GB.plg_fields_fieldName.sys.ini
media
  |
  -- css
    |
    -- fieldName.css
  -- js
    |
    -- fieldName.js
params
  |
  -- fieldName.xml
tmpl
  |
  -- fieldName.php
fieldName.php
fieldName.xml
  • fields/fieldName.php is a custom JForm field. You can add as many custom JForm fields to this directory as you need.
  • language/ contains the language definition files are located.
  • media/ is an optional directory for supporting media like CSS and JavaScript files.
  • params/ contains the form field definitions used when creating a custom field instance in the component configuration.
  • tmpl/fieldName.php is the frontend template used for rendering the field.
  • fieldName.php is the plugin entry point.
  • fieldName.xml is the plugin manifest file used for installation.

Resources

The custom field plugin uses the JForm API so the standard Joomla field types as used in an extension's .xml file, are applicable, just written differently, in a .php file.

File (upload) form field

For a file form field, you need a destination to upload to. Some options:

  1. Develop a simple ajax plugin to acept the upload.
  2. Add an admin template override add enctype="multipart/form-data" to the form tag. This has the side effect of that field not being available in the jcfields #item object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment