I think I'm going mad here, or don't understand basics.

I have created custom field type in a plugin. It installs and works in Article: Add custom field.

The problem is I can't make it work with my created and working custom component.

I've tried adding it by namespace:
<form addfieldprefix="[COMPANY]\Plugin\Fields\[Fieldname]\Field">

I've tried event with file path:
<form addfieldpath="/plugins/fields/[fieldname]/src/Field">

Is there something I have to add on component itself or modify the plugin/field or is it simply not doable?

I also tried to load it in core components and it didn't work either.

Currently working on Joomla 5 and both component and plugin are with the namespace architecture.

edit 1:
I'm gonna go ahead and add another question. Is this the case that I need to make it a system plugin rather than field plugin to have access to onAfterInitialise (or some other event) to be able to actually add field type via FormHelper::addFieldPrefix() or is it overkill?

I think I figured it out. I realized FormBehaviorTrait is dispatching event onPrepareForm and it works.
First I want to use this trait in my model but then I figured "Hey, I have my own override for preprocessForm method so why not just write dispatch there."
And it works!

It still leaves me with that awful feeling like it could be done better. Can anyone suggest something or confirm that this is the way?

  • The attribute should be addfieldprefix, not addprefix.
    – Sharky
    Commented Jun 25 at 13:29
  • @Sharky You are correct, tho it's just a typo in the question. I tried before with addfieldprefix and it is not working.
    – S-C
    Commented Jun 25 at 14:31

1 Answer 1


Since there are no additional comments or answers, I will assume my approach was valid and I will post it here as an answer.

After further digging I found out that FormBehaviorTrait dispatches event onPrepareForm which is perfect for loading the field prefix.

The downside, or rather the inconvenience, of this approach is the requirement to create a getFormFactory method. This is not a big deal, but also not really something I'm willing to spend my time on.

I copied the dispatch part from preprocessForm method of the trait into my component's model and added the prepareForm event method in the plugin. This way worked for me.

  • If you have answered your own question, please be sure to mark the original question as answered.
    – Terry Carter
    Commented Jun 28 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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