Joomla 4 Custom Field Types in subforms

411 views
Skip to first unread message

Peter Tuson

unread,
Mar 11, 2022, 10:57:05 AM3/11/22
to Joomla! General Development
For our application we developed a very complex set of forms as part of our custom profile plugin; this all worked fine up to Joomla 3.

I have now converted it to Joomla 4 and most of the forms are working correctly. The only problem is with custom field types within subforms. The subforms themselves are displaying well with the standard fields showing correctly. The fields with the custom field types only show the previously entered value and there is no selection available - like a text field.

I checked the related field code and that is not being called. There are no errors being raised.

I have looked at the subformfield code. This loads the form and the form data using the
Form method getInstance, which calls the FormFactory to get the form. This creates a new Form using the data supplied but doesn't get the custom fields.

I use custom fields elsewhere within the forms not within subforms and they are working correctly.

Please Help.

Regards,
Peter

Peter Tuson

unread,
Mar 14, 2022, 11:16:12 AM3/14/22
to Joomla! General Development
I have managed to fix this. There were two problems. Firstly when searching for the custom field, if it is not found then the code assumes it is a TextField without bothering to inform us. In this case it could not find the field because I didn't realise that it was case sensitive so I called my fields like TopicListField but it will only find TopiclistField. In addition, I had to include:  use Joomla\CMS\Form\FormHelper; and FormHelper::addFieldPrefix('Company\Plugin\User\PluginName\Field'); in the tmpl php file that was responsible for displaying the data.

I used the Joomla user profile plugin as my template.

Now all 20 fields seem to be working properly.

Regards,

Peter.

mor...@moledesign.biz

unread,
Mar 15, 2022, 9:01:35 AM3/15/22
to Joomla! General Development
The Joomla user profile plugin you mentioned, was it the 2.5 / 3 template or is there a new Joomla 4 template to use?

Peter Tuson

unread,
Mar 15, 2022, 9:30:25 AM3/15/22
to Joomla! General Development
I am using the standard Cassiopeia template within Joomla 4. My previous custom templates don't work on Joomla 4.

Regards,

Peter.
Reply all
Reply to author
Forward
0 new messages