As explained in the manual, you can use shown
attributes within <option>
tags since this PR: #18998
This works for com_config
if you try, but it does not (always) work for other components.
/media/system/js/showon.min.js
is not automatically loaded. I think there's either a bug, or the manual is missing this info.your/site/media/system/js
, which should show showon.min.js
.https://website/administrator/index.php?option=com_config
. But if you go to https://website/administrator/index.php?option=com_banners&view=banner&layout=edit
you'll see showon.min.js
is missing.Either update the manual or the Joomla code. I don't know what's preferred.
If you'll manually add the following to your existing component's joomla.asset.json
:
{
"name": "showon",
"type": "script",
"dependencies": [
"core",
"showon.es5"
],
"uri": "system/showon.min.js",
"attributes": {
"type": "module"
},
"version": "bfc733e48a923aaffb3d959cd04f176bad7d7d52"
}
And load this script with the web asset manager:
$wa = $this->document->getWebAssetManager();
$wa->useScript('showon');
Then it should work as expected.
It's key for this bug report to try the shown
feature within an <option>
tag, because it does always work within a <field>
tag.
Joomla! 4.1.0 Stable
Labels |
Added:
No Code Attached Yet
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-03-17 09:30:55 |
Closed_By | ⇒ | richard67 |
Status | Closed | ⇒ | New |
Closed_Date | 2022-03-17 09:30:55 | ⇒ | |
Closed_By | richard67 | ⇒ |
Re-opening as the pull request was closed.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-04-01 16:37:12 |
Closed_By | ⇒ | richard67 |
Expected behaviour. If you need theshowon
you have to load the script. Also you don't have to copy the system JSON to your component, just load it directly$this->document->getWebAssetManager()->useScript('showon')
Joomla is not following the old patterns, eg loading JS/CSS global, if the developer needs a specific JS/CSS they have to load it, per instance but this is a bug