5

I am looking for some information about how to create a custom field type for joomla 3.7 core custom fields. Can anyone point me in the direction of a tutorial, an example of anything that may help with the process? I couldn't find official documentation on that.

Please note I am not talking about adding the field to an article, I am talking about creating a new type of field that can be selected from the custom fields component.

Thanks

  • I Figured it is just a plugin so I went to copy a core existing one to then expand on that. However I copied the imagelist, renamed it all to newimagelist, installed all without problem. Created a new field, went into an article but the newly created field which is just a copy doesn't behave same way. The list dropdown doest work. Any ideas? – user5294803 Jun 12 '17 at 6:49
  • You might find some info in Digital Peak's presentation at Joomladay Germany last year about creating a custom field for Joomla! joomla.digital-peak.com/images/blog/… – Wim de Ruijter Aug 3 '17 at 11:38
1

It seems that fields are simply plugins of type fields. I simply copied the text folder from /plugins/fields, to a new folder, text2. I also changed the names of the files inside the text-folder to text2.php and text.xml, and /tmpl/text2.php. In text2.xml there is a reference to the plugin name, update this as well, like:

<files>
    <filename plugin="text2">text2.php</filename>
    <folder>params</folder>
    <folder>tmpl</folder>
</files>

Now you are ready to use the discover - tool in the joomla administrator, to discover the new plugin. Go to yoursite/administrator/ and find the menu extensions/manage/discover. Click discover, the new plugin should be listed. Install the new plugin. Afterwards, find the new plugin in extensions/mange, and enable it.

Now you should be able to add a new custom field for eg. an article, using your brand new, custom, self made field...

There is a lot of info about writing your own plugin, eg:

https://docs.joomla.org/J3.x:Creating_a_Plugin_for_Joomla

0

From what I understand, the custom field type references a system field type of the same name. So when you copied the custom field plugin and renamed it, it now referenced a system field type that didn't exist.

I'm looking at doing the same thing, but it's a lot more work than just creating a plugin.

0

You can copy one of the fields in:

\libraries\joomla\form\fields

to:

\components\com_yourcomponent\models\forms\fields

and rename the copied field. Then change data of your new custom filed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.