J3.x

J3.x:Developing an MVC Component/Adding Custom Fields

From Joomla! Documentation

Revision as of 20:05, 4 April 2020 by Robbiej (talk | contribs) (Page creation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This tutorial is part of the Developing an MVC Component for Joomla! 3.2 tutorial. You are encouraged to read the previous parts of the tutorial before reading this.

In this part, we will cover the various aspects of enabling custom fields to be added to our helloworld component.

Introduction

Joomla 3.7 included the capability to define custom fields associated with some of the core Joomla components, and this feature was designed in a way that could be easily included in custom components. If you're not familiar with custom fields it's worth going through the Adding custom fields tutorial and experimenting using the custom fields available with com_content and com_contact for example.

Functionality

Here is a list of the functional changes for this step.

Admin Field Definition

We provide administrators with a way of defining the custom fields which can be added to our helloworld records. We do this by adding "Fields" and "Field Groups" to the sidebar submenu which was built in the Adding Categories step.

We'll also allow admins to set custom fields against our helloworld categories – so that when they click on Fields in the sidebar submenu there's a context dropdown to the left of the filter fields at the top.

Admin Setting Field Values

Once the fields are defined they are available to be used for our helloworld component. But we have to extend our "edit" form (which enables adding and editing helloworld records) to allow admins to enter values of the custom fields associated with each helloworld record.

We also want to allow admins to set values in custom fields of helloworld categories.

Admin Field Permissions

We define the permissions relating to managing Fields and Field Groups for our component. This then enables suitably authorised admins to define which user groups can edit fields and field groups, or enter data for custom fields.

Front-end Presentation

We extend the Hello World front end page to display the custom field values associated with that helloworld record.




Contributors