<field name="social_auth_providers" type="list" default="facebook,twitter,google" multiple="true" layout="joomla.form.field.list-fancy-select" label="Social" description="Social">
<option value="facebook">Facebook</option>
<option value="google">Google</option>
<option value="twitter">Twitter</option>
<option value="linkedin">LinkedIn</option>
</field>
<field name="facebook_oauth_id" type="text" showon="social_auth_providers:facebook" label="Facebook" description="Facebook"/>
The second field is shown when the option with the value facebook is selected in the list field.
The second field is not shown
Joomla 4.0.2
This works fine in Joomla 3.10
Labels |
Added:
No Code Attached Yet
|
Does it work if you remove the multiple="true"
? I'm not sure it's supposed to work with multiple.
Joomla 4: It works when the list is single selection (no multiple=true), it does not work with multiple=true.
Joomla 3: Works for both
@Fedik @dgrammatiko Did any of you change the showon JS code for J4? Could that be the issue here?
Did any of you change the showon JS code for J4?
Yes, the showon is completely rewritten in J4 as vanilla JS (no jQuery) but I think the problem comes from the field, eg probably the choices.js part or the parent Custom Element. The first one I wrote the code for the other was @Fedik (I think, might be wrong)
No, removing the layout attribute shows a multi-select list box. Selecting options does not show other fields.
thanks for checking,
so it seems the bug in shwoon js, need to look how it handle multiple values
If someone can test replacing this
joomla-cms/build/media_source/system/js/showon.es6.js
Lines 138 to 156 in cabe406
// If checkbox or radio box the value is read from properties
if (originField.getAttribute('type') && ['checkbox', 'radio'].includes(originField.getAttribute('type').toLowerCase())) {
if (!originField.checked) {
// Unchecked fields will return a blank and so always match
// a != condition so we skip them
return;
}
itemval = document.getElementById(originId).value;
} else if (originField.nodeName === 'SELECT' && originField.multiple) {
itemval = Array.from(originField.querySelectorAll('option:checked')).map(el => el.value);
} else {
// Select lists, text-area etc. Note that multiple-select list returns
// an Array here s0 we can always treat 'itemval' as an array
itemval = document.getElementById(originId).value;
// A multi-select <select> $field will return null when no elements are
// selected so we need to define itemval accordingly
if (itemval === null && originField.tagName.toLowerCase() === 'select') {
itemval = [];
}
}
The solution should be either that or something similar (I can't test this atm)
that will not work, there no field type="select"
should be element.nodeName === 'SELECT'
Hello,
Today I came across the same problem. Showon in Joomla 4 doesn't work for field list when it has 'multiple' attribute (as mentioned before) and also doesn't work for field of type 'checkboxes'.
Title |
|
Same issue here.
I almost submitted a new issue! I wrote this description:
type="list"
, it still works OKlayout="joomla.form.field.radio.switcher"
, it still works OKmultiple="true"
to the save_history (list), the shown conditional field doesn't work. <field
name="save_history"
type="list"
label="JGLOBAL_SAVE_HISTORY_OPTIONS_LABEL"
default="0"
multiple="true"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
The shownon
behaviour must support the multiple
attribute (as it worked before on Joomla 3)
The shownon
behaviour doesn't support the multiple
attribute.
@anibalsanchez can you test #35486 (comment)
@dgrammatiko The comment was almost there. I was writing about the array name just when you submitted the PR. ;-)
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-10-02 09:34:58 |
Closed_By | ⇒ | alikon |
Works for me with J! 4.0.2. Well, I've only tried it with the field type of radio not list.