User tests: Successful: Unsuccessful:
(Resurrection of old Pull Request #17212 where the fork/branch got royally messed up)
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:
$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.
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'
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
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.
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.
As explained above.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries JavaScript |
Labels |
Added:
?
|
Can we get this merged please - it adds a useful configuration feature to JForm with minimal code changes
Like all pr it needs testers
@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
Thank you!!
I have tested this item
Tested, working well. Don't see any issues at all.
I have tested this item
Tested correctly with different advanced combinations of showon:
Form File: administrator/components/com_content/config.xml
Success!!
Testing code(line 498):
<option value="1" showon="targeta:1[OR]targeta:2">JBROWSERTARGET_NEW</option>
Success!!
Testing Code (Line 513):
<option value="1" showon="targeta:1[AND]targetb:1">JBROWSERTARGET_NEW</option>
Success!!
Status | Pending | ⇒ | Ready to Commit |
Ready to Commit after two successful tests.
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:
?
|
@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 :( )