Skip to content

[5.4] Fix regex pattern in ShowOnRule for custom fields#47474

Merged
muhme merged 2 commits intojoomla:5.4-devfrom
LadySolveig:5.4/fix/regex-showon-rule
Mar 31, 2026
Merged

[5.4] Fix regex pattern in ShowOnRule for custom fields#47474
muhme merged 2 commits intojoomla:5.4-devfrom
LadySolveig:5.4/fix/regex-showon-rule

Conversation

@LadySolveig
Copy link
Copy Markdown
Contributor

@LadySolveig LadySolveig commented Mar 25, 2026

Pull Request resolves # .

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

As it is a valid condition in the XML form for the showon attribute to have something like foo: to display a field only if another field is empty, this should also be possible via the custom fields.

Testing Instructions

1. Add two custom fields in Articles: Fields (text or textarea - doesn't matter)

grafik

2. Add foo: as showon rule into the field in the options tab

grafik

3. Additional tests

  • using various combinations of fields, such as Select, etc
  • OR conditions such as foo:[OR]foo:0 or foo:0[OR]foo:
  • check whether other conditions are working as before
  • test the other way around foo!: - the bar field should now only be displayed if the foo field is not empty

Actual result BEFORE applying this Pull Request

Rejected by validation.

grafik

Expected result AFTER applying this Pull Request

Can be saved and works the same way just like we've been doing all along, by inserting directly into the XML form

grafik

The bar field will now only be displayed if the foo field is empty.

ssitdocker.test_j54_administrator_index.php_option.com_content.view.articles.Laptop.2026-03-25.18.04.09.mp4

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@LadySolveig LadySolveig changed the title Fix regex pattern in ShowOnRule for custom fields [5.4] Fix regex pattern in ShowOnRule for custom fields Mar 25, 2026
@richard67 richard67 added the bug label Mar 25, 2026
@richard67
Copy link
Copy Markdown
Member

3. Additional tests

* using various combinations of fields, such as Select, etc

* `OR` conditions such as `foo:[OR]foo:0` or `foo:0[OR]foo:`

* check whether other conditions are working as before

@LadySolveig Maybe another additional test for a condition !foo: would be useful to see if that is not broken?

I know, it is covered by the last point "check whether other conditions are working as before".

But maybe it should be explicitly mentioned?

@exlemor
Copy link
Copy Markdown

exlemor commented Mar 26, 2026

I have tested this item ✅ successfully on 6e0e00b

I have tested this successfully... Thanks @LadySolveig! (solving useful things I didn't know we had in Joomla ;) )

I also tested foo:[OR]foo:0 or foo:0[OR]foo: and foo!: which all worked as expected.

@richard67 I assume you meant foo!: and not !foo: (as !foo: did yield the same error message of Invalid field: Showon Attribute) while foo!: saved and behaved in the expected opposite manner of foo:


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47474.

@krishnagandhicode
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 6e0e00b


Everything works as expected(also verified the edge cases - foo!: and foo:[OR]foo:0, and they saved perfectly).

On a personal note: I recently learned about regular expressions in my Formal Theory of Automata course, so seeing this regex fix in action is really cool.

Thanks @LadySolveig : )


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47474.

@LadySolveig
Copy link
Copy Markdown
Contributor Author

Thank you for testing it, @exlemor and @krishnagandhicode! 💚

I really appreciate your personal note. Keep that curiosity and open-mindedness!
The great thing about open source is that throughout our lives, we’ll keep coming across exciting things that we’d previously only heard about in theory.

@richard67
Copy link
Copy Markdown
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47474.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 26, 2026
@muhme
Copy link
Copy Markdown
Contributor

muhme commented Mar 31, 2026

✅ Final test before merge with JBT

  • Seen error before,
  • Created text1, text2 and text3
  • Tested text3 showon attributes 'text1:', 'text1!:', text1:[OR]text1:0 and 'text1!:[OR]text2!:'

@muhme muhme merged commit 66602c7 into joomla:5.4-dev Mar 31, 2026
126 of 137 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 31, 2026
@muhme muhme added this to the Joomla! 5.4.5 milestone Mar 31, 2026
@muhme
Copy link
Copy Markdown
Contributor

muhme commented Mar 31, 2026

Thank you @LadySolveig for your contribution. Thank you @richard67 for support. Thank you @exlemor and @krishnagandhicode for testing.

@LadySolveig LadySolveig deleted the 5.4/fix/regex-showon-rule branch April 18, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants