?
avatar bassmanpaul
bassmanpaul
1 Jul 2016

I ran into a scenario where 2 JForm instances are on the same page. Each instance's XML used addfieldpath="/components/com_comp1/models/fields". Each field location had a JForm field called layout which were completely unrelated. However, because the field paths are loaded statically, both instances will use the highest loaded layout custom field.

Steps to reproduce the issue

  • Load two JForm instances on one page,
  • Each with its own addfieldpath="" location to 2 separate places (e.g. component & plugin).
  • Each field location has a field with the same name but 2 different applications.
  • One out-prioritises and loads into both instances.

Expected result

Each JForm instance should have the field location specified in the XML.

Actual result

Each JForm instance receives both path locations as they are set statically.

System information

Joomla 3 with any environment & browser.

Additional comments

As there isn't any namespace ability like JLayout perhaps if there was a JForm::removefieldpath() we could manually fix our conflicts but ideally if an XML instance has a addfieldpath="" present, this shouldn't load into other instances of JForm should it?.

Thoughts welcome :)

avatar bassmanpaul bassmanpaul - open - 1 Jul 2016
avatar mbabker
mbabker - comment - 1 Jul 2016

For me part of the problem is in the fact that there is very little documentation or actual demonstrated use of JForm's namespacing ability to convert a field type to a class name. A couple of examples:

  • type="text" results in a class name of JFormFieldText
  • type="my.text results in a class name of MyFormFieldText

The stats plugin actually does use namespacing for fields.

You could probably fix your own code by namespacing stuff but you can't really deal with third party uses which may or may not do the same and create the same potential issues down the line.

I'm personally not a fan of "remove lookup instruction" methods like your suggested removeFieldPath() method. Especially since all of these methods (i.e. in the MVC layer, JTable, JHtml, and JForm) are all static and global versus per instance so such a removal has more potential to break stuff than not.

avatar brianteeman brianteeman - change - 1 Jul 2016
Labels Added: ?
avatar bassmanpaul
bassmanpaul - comment - 4 Jul 2016

No way! I actually have JForm & JField's classes permanently open for reference & I still missed that feature!

I agree, namespacing is a much better solution than post removal logic. Thanks for pointing that out.

avatar bassmanpaul bassmanpaul - change - 4 Jul 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-07-04 08:31:43
Closed_By bassmanpaul
avatar bassmanpaul bassmanpaul - close - 4 Jul 2016

Add a Comment

Login with GitHub to post a comment