? ? Pending

User tests: Successful: Unsuccessful:

avatar GeraintEdwards
GeraintEdwards
6 Dec 2017

(Resurrection of old Pull Request #17212 where the fork/branch got royally messed up)

Summary of Changes

The showon attribute currently works for fields in Jforms to allow their display to be conditional on the value of another field. This PR makes some simple changes to enable this functionality to work on list option value too - in other works the display of a specific list option can now be dependent on the value of another field.

The changes required to make this work are minimal:

  1. In libraries/joomla/form/fields/list.php we add pass new attribute name as an option

$listoptions['option.attr'] = 'optionattr';

this means that the list renderer will use the option.attr value we pass in to add additional attributes to the option.

  1. In the getOptions method of libraries/joomla/form/fields/list.php we look for a 'showon' attribute and if its specified pass it as 'optionattr'

  2. In media/jui/js/cms-uncompressed.js/media/jui/js/cms.js we have to disable the normal animation effect for option values (this does work in Chrome but not in other browsers) and add some special handling to toggle the display of the option and trigger an update in the chosen display where needed).

So all in all minimal changes

Testing Instructions

Best test is to edit an existing form e.g. administrator/components/com_content/config.xml and look for the declaration of targetb and add a showon attribute e.g.

<option value="1" showon="targeta:1">JBROWSERTARGET_NEW</option>

This make the browser new option in the URL b target drop down dependent on the value of URL a target drop down.

Expected result

When you edit the articles options and set URL A target drop down equal to 'new browser window' this option is available for URL B but otherwise its hidden.

optionvisible

optionhiden

Actual result

As explained above.

Documentation Changes Required

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
3.00

avatar GeraintEdwards GeraintEdwards - open - 6 Dec 2017
avatar GeraintEdwards GeraintEdwards - change - 6 Dec 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 6 Dec 2017
Category Libraries JavaScript
avatar GeraintEdwards
GeraintEdwards - comment - 6 Dec 2017

@C-Lodder @dgt41 please continue the discussion of the previous PR here (sorry I messed up my local branch/fork and had to start again :( )

The showon code needs a lot of work:

It really slow using jQuery and a large form (I have a prototype version implemented using native query selectors with a pseudo polyfill that falls back to jQuery where the query selector methods don't exist)
the toggle needs to be replaced with a CSS transition (this is a very small performance benefit compared to the gains available from improving the finding of conditional elements and processing them on large forms)
the toggle/its replacement needs to respect the original CSS state - e.g. a div shouldn't be reset to block if it was an inline-block beforehand
the xml syntax should allow for and/or to be combined intelligently with appropriate associative ordering/parenthesis support

A lot of this could be done before 4.0 and I propose putting a PR together to deal with it in the next couple of weeks.

In the meantime cane we move forward with this PR please?

avatar GeraintEdwards GeraintEdwards - change - 6 Dec 2017
The description was changed
avatar GeraintEdwards GeraintEdwards - edited - 6 Dec 2017
avatar GeraintEdwards GeraintEdwards - change - 6 Dec 2017
Labels Added: ?
avatar GeraintEdwards
GeraintEdwards - comment - 5 Feb 2018

Can we get this merged please - it adds a useful configuration feature to JForm with minimal code changes

avatar brianteeman
brianteeman - comment - 5 Feb 2018

Like all pr it needs testers

avatar tonypartridge
tonypartridge - comment - 30 Mar 2018

@Quy @ggppdk could you guys pretty please run some tests? :-) It would be hugely appreciated!

avatar ggppdk
ggppdk - comment - 30 Mar 2018

@tonypartridge @GeraintEdwards

I remember this PR
This will be a nice feature for both configuration and content forms, it will be useful for several core and 3rd party extensions, it will give a better UX

I ll try to test by Monday if it does not get enough tests by then

avatar tonypartridge
tonypartridge - comment - 30 Mar 2018

Thank you!!

avatar tonypartridge
tonypartridge - comment - 2 Apr 2018

I have tested this item successfully on 9cc2b07

Tested, working well. Don't see any issues at all.


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

avatar tonypartridge tonypartridge - test_item - 2 Apr 2018 - Tested successfully
avatar carcam
carcam - comment - 4 Apr 2018

I have tested this item successfully on 9cc2b07

Tested correctly with different advanced combinations of showon:

Form File: administrator/components/com_content/config.xml

Test proposed by @GeraintEdwards

Success!!

Test OR syntax

Testing code(line 498):

<option value="1" showon="targeta:1[OR]targeta:2">JBROWSERTARGET_NEW</option>

Success!!

Testing AND syntax

Testing Code (Line 513):

<option value="1" showon="targeta:1[AND]targetb:1">JBROWSERTARGET_NEW</option>

Success!!


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

avatar carcam carcam - test_item - 4 Apr 2018 - Tested successfully
avatar franz-wohlkoenig franz-wohlkoenig - change - 4 Apr 2018
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 4 Apr 2018

Ready to Commit after two successful tests.

avatar mbabker mbabker - close - 12 May 2018
avatar mbabker mbabker - merge - 12 May 2018
avatar mbabker mbabker - change - 12 May 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-05-12 18:39:43
Closed_By mbabker
Labels Added: ?

Add a Comment

Login with GitHub to post a comment