Create custom field type?

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
sim085
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Mon Oct 04, 2010 4:11 pm

Create custom field type?

Post by sim085 » Sun Jul 08, 2018 6:16 pm

Hello, I am trying to create my own custom field type. On google I can find many example how to add existing custom field types which come with Joomla however I am more interested in creating my own type.

So far I have tried to build my own custom field type by looking at the fields that come with Joomla. However I am getting stuck in the part where I come to display the component in the backend when setting the value of the field from an article. I can see that the code makes reference to "FieldsPlugin" however I cannot understand how this is being setup.

Using the colour picker field as an example, from the article page trying to edit this field shows a colour picker. When I check the code of the colour picker (/plugins/fields/color/color.php) I can see that "PlgFieldsColor" extends "FieldsPlugin". This is also the base class of PlgFieldsText however I can't understand what these two are doing differently so that for one it shows the colour picker while for the other it doesn't.

Does anyone know of a simple tutorial to create your own custom field type?
Last edited by imanickam on Mon Jul 09, 2018 3:15 am, edited 1 time in total.
Reason: Moved the topic from the forum Extensions for Joomla! 3.x to the forum Joomla! 3.x Coding

User avatar
donnan
Joomla! Ace
Joomla! Ace
Posts: 1494
Joined: Sat Jun 30, 2007 1:23 am
Location: Sydney, Australia
Contact:

Re: Create custom field type?

Post by donnan » Mon Jul 09, 2018 3:26 am

do you mean you wish to create a Field Group?

I created a custom group. Goto Users then Field Groups. Create the group you want then you can create the fields for that group in Users/Fields.

sim085
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Mon Oct 04, 2010 4:11 pm

Re: Create custom field type?

Post by sim085 » Mon Jul 09, 2018 6:32 am

No not a field group but my own custom field type. For example imagine I want a date of birth picker. At the moment the field that would come close to this is the "Calendar" field. However imagine I do not want a Calendar. I want three drop downs with one drop down for day, another for month and another for year, one next to each other.

I know I can create a field group named "Date of Birth" with three drop downs but what I really want is one field with three drops downs. How would I go about and develop that?

In other words develop a new field (type) which when added this would show in the backend article field tab I would have a field with label set to "Date of Birth" (as defined by user when creating the field) and the field input part would be made of three drop downs as explained above.

Please note this is just an example; I am not looking for this plugin but rather trying to understand how I can develop such a plugin.
donnan wrote:do you mean you wish to create a Field Group?

I created a custom group. Goto Users then Field Groups. Create the group you want then you can create the fields for that group in Users/Fields.

User avatar
donnan
Joomla! Ace
Joomla! Ace
Posts: 1494
Joined: Sat Jun 30, 2007 1:23 am
Location: Sydney, Australia
Contact:

Re: Create custom field type?

Post by donnan » Mon Jul 09, 2018 6:53 am

you could probably clone the FieldPlugin and just write what you need to do in their.

pepperstreet
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sat Apr 17, 2010 1:53 am
Location: Hamburg
Contact:

Re: Create custom field type?

Post by pepperstreet » Tue Jul 10, 2018 10:12 pm

sim085 wrote:Does anyone know of a simple tutorial to create your own custom field type?
Maybe this article is of any help:
https://coolcat-creations.com/en/blog/t ... eld-plugin

sim085
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Mon Oct 04, 2010 4:11 pm

Re: Create custom field type?

Post by sim085 » Sun Jul 15, 2018 7:00 am

Thanks for the link. This example and her other examples on github helped me a lot.
pepperstreet wrote:
sim085 wrote:Does anyone know of a simple tutorial to create your own custom field type?
Maybe this article is of any help:
https://coolcat-creations.com/en/blog/t ... eld-plugin


Locked

Return to “Joomla! 3.x Coding”