4

I am looking at how to create my own custom field using a self implemented form field in Joomla 5.

I started my extension in the same way as the core extensions (https://github.com/joomla/joomla-cms/tree/5.0-dev/plugins/fields/) and put my own field in the /src/Field directory of my Extension.

I have also tried to add the path via

FormHelper::addFieldPath(JPATH_PLUGINS . '/' . $this->_type . '/' . $this->_name . '/src/Field');

But my form field does not seem to be found. I think this, because the type is always set to the default text.

I now wanted to do further research. But I can't find the place where the form field is set. I only find a getField() here. But no setField().

Where do I have to look?

Is there perhaps an example of a custom field that uses a self-created form field?

1 Answer 1

1

My attempts so far have ended in code that does not load the form field either.

I have created a question on Github. See: https://github.com/joomla/joomla-cms/discussions/42246

Here I found the solution in

For namespaced field you need to use FormHelper::addFieldPrefix() to register your namespace in the form, instead of FormHelper::addFieldPath(). Example FormHelper::addFieldPrefix('Foo\Bar') for field Foo\Bar\BeerField

1
  • I've just begun working with Joomla 5. Which file did you add the statement FormHelper::addFieldPrefix() to?
    – kalinma
    Commented Aug 27 at 22:39

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.