joomla/joomla-platform — Issue #455: loadElement only includes first matched element file. Problem with multiple elements with same main name.
Author: nonumber
Created: 2011-10-22 09:24:26+00:00
State: open

Sorry for the long explanation here, but it probably makes the problem clear enough:

When having admin views like the module edit page, you have the JForm elements on the right. These are different fields.
The different xml files that are used to create these (some of module itself, some of core, etc) can have an addpath to include extra field files.

So far so good. But, if there are field files with the same file name, things go haywire...

Now there is a possibility to call on these field types with prefixes, to prevent duplicate class names.
Like in my case I have a type="nn_categories"
This will act on the class JFormFieldNN_Categories in the file categories.php in the addpath location. Note, it doesn't look for nn_categories.php but for categories.php

So my thought is that the function that loads the files from the different addpaths shouldn't stop at the first filename that matches (categories.php), put should look for the file that actually has the correct classname (JFormFieldCategories vs JFormFieldNN_Categories vs JFormFieldXXX_Categories)

So there is a problem when 2 extensions (plugins/whatever) are involved in creating the form.
Each with their own addpath and with their own extra field files.
So the first could use type="a_categories" and the second uses type="b_categories".

However, Joomla only loads the first categories.php. So only the first JFormFieldA_Categories is initialized. And not the second JFormFieldB_Categories - causing all b_categories fields to default to a default text field.
Essentially I think the prolem is in file:
\libraries\joomla\html\parameter.php
in the loadElement method.

Instead of looping through all dirs and including all files that match (maybe double checking for duplicate classnames), it simply does a:
JPath::find($dirs, $file)
Which returns the path of the first file that matches....

It should do a while loop through the dirs, checking if the required class exists in the condition..