? Pending

User tests: Successful: Unsuccessful:

avatar Harmageddon
Harmageddon
10 May 2020

Form definitions in XML allow the usage of add(field|form|filter|rule)(path|prefix) to add form fields, forms, filters and rules from specified paths. Right now, this only works for single values. This means, if you want to import fields from two different locations, you need to specify them for example like this:

<fields name="params" addfieldpath="path/to/first/fields">
  <fieldset name="basic" addfieldpath="path/to/second/fields">

This separation of the two paths is not logically motivated. Second, it introduces a limitation on the number of paths you can add. If you have a structure form > fields > fieldset, you can enter at most three paths. To add more, you'd have to introduce empty dummy fieldsets at the end of the file.

Summary of Changes

This PR introduces the possibility to add multiple paths in a single argument, separated by comma. This reduces the above example to:

<fields name="params">
  <fieldset name="basic" addfieldpath="path/to/first/fields,path/to/second/fields">

Testing Instructions

  1. Make sure all forms using addfieldpath, addfieldprefix, addfilterpath, addfilterprefix, addformpath, addformprefix, addrulepath, and addruleprefix still work as before.
  2. Either write your own forms using two values for these attributes, or use the plugins I wrote:

Demo Plugins

I wrote https://github.com/Harmageddon/plg_demo_addfieldpath and https://github.com/Harmageddon/plg_demo_addfieldprefix for testing. As they use cross-references between each other, both need to be installed at the same time.

plg_demo_addfieldpath

This plugin aims to test the add*path functionalities. The form should contain the following fields:

  • An article modal field to test the first value of addfieldpath.
  • A menu item modal field to test the second value of addfieldpath.
  • A "Filter and Rule test" field that requires an "a" to be entered by the rule. The filter converts text from lower to upper case. This tests the first value of addfilterpath and addrulepath.
  • A "Filter and Rule test 2" field that requires a "b" to be entered by the rule. The filter converts text from upper to lower case. This tests the second value of addfilterpath and addrulepath.
  • Two subform fields, one with color values and one with numbers to test both values for addformpath.

plg_demo_addfieldprefix

This plugin aims to test the add*prefix functionalities. The form should contain the following fields:

  • An article modal field to test the first value of addfieldprefix.
  • A menu item modal field to test the first value of addfieldprefix.
  • A "Filter and Rule test" field that requires a number to be entered by the rule. The filter converts text from lower to upper case. This tests the first value of addfilterprefix and addruleprefix.
  • A "Filter and Rule test 2" field that requires an "a" to be entered by the rule. The filter converts text from upper to lower case. This tests the second value of addfilterprefix and addruleprefix.

I couldn't find any usage of addformprefix, so if someone has an idea how to test this, I'm open for suggestions.

Documentation Changes Required

Could be noted at https://docs.joomla.org/Creating_a_custom_form_field_type#Linked_with_a_form or https://docs.joomla.org/Advanced_form_guide.

avatar Harmageddon Harmageddon - open - 10 May 2020
avatar Harmageddon Harmageddon - change - 10 May 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 10 May 2020
Category Libraries
avatar Harmageddon Harmageddon - change - 10 May 2020
Labels Added: ?
avatar HLeithner
HLeithner - comment - 10 May 2020

A comma is a valid path character, we need another character for this that works on windows and posix filesystems.

avatar Harmageddon
Harmageddon - comment - 10 May 2020

Oh, I see. Maybe a colon could work for Windows? But for POSIX, I can't find any reserved characters that can't be included in paths, except the null byte. But maybe we can assume that extension developers don't include colons in their folder structure?

avatar HLeithner
HLeithner - comment - 10 May 2020

based on the comment by @Bakual on glip you can add the path to every xml-tag so you can add it to the field it self too. In this case I don't think it's worth to add this logic.

avatar Harmageddon
Harmageddon - comment - 11 May 2020

You're right. Because of the documentation and the examples in core, I thought, these attributes needed to be in a form or fieldset tag. But every of these attributes can be added directly to the respective field tag. And I don't see any scenario where you would need more than one value for a single field. So I'm closing this here.

Thanks to @Bakual for pointing this out! :-)

avatar Harmageddon Harmageddon - close - 11 May 2020
avatar Harmageddon Harmageddon - change - 11 May 2020
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2020-05-11 16:35:08
Closed_By Harmageddon

Add a Comment

Login with GitHub to post a comment