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?
Update
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?
addfieldprefix
, notaddprefix
.