User tests: Successful: Unsuccessful:
Pull Request for Issue #37851 .
Adds an id attribute to the hidden input element when a list field is read-only
The id attribute is required for the showon function as it uses the field's id to get the value.
In the core I do not find this situation but a workaround for that case (added with #33096). Here the showon attribute is cleared or the field removed ...
joomla-cms/administrator/components/com_fields/src/Model/FieldModel.php
Lines 566 to 577 in 4f1a4f1
Add following code to administrator/components/com_content/forms/article.xml
copy template:
<fieldset name="showontest" label="SHOWONTEST">
<field
name="list1"
type="list"
label="LIST ENABLE"
default="0"
>
<option value="0">VALUE 0</option>
<option value="1">VALUE 1</option>
</field>
<field
name="text1"
type="text"
label="TEXT 1"
showon="list1:1"
/>
<field
name="list2"
type="list"
label="LIST DISABLE"
default="0"
readonly="true"
>
<option value="0">VALUE 0</option>
<option value="1">VALUE 1</option>
</field>
<field
name="text2"
type="text"
label="TEXT 2"
showon="list2:1"
/>
</fieldset>
A js error exists because getElementById fails:

TEXT1 is only visible when field LIST ENABLE have value VALUE 1TEXT2 is visible but should not
No longer a js error
TEXT1 is only visible when field LIST ENABLE have value VALUE 1TEXT2 is not visible because field LIST DISABLE have value VALUE 0
Please select:
| Category | ⇒ | Layout |
| Status | New | ⇒ | Pending |
| Labels |
Added:
?
|
||
Try changing
to:} else if (originField.nodeName === 'SELECT' && originField.hasAttribute('multiple') && !originField.hasAttribute('disabled')) {I haven't tested the code, maybe you can share some subform to make debugging easier
Try changing
@dgrammatiko I think it don't work because the originField is no longer a select

<div class="controls">
<select id="jform_list4" name="" class="form-select" multiple="" disabled="disabled">
<option value="0" disabled="disabled" selected="selected">VALUE 0</option>
<option value="1" disabled="disabled">VALUE 1</option>
<option value="2" disabled="disabled" selected="selected">VALUE 2</option>
</select>
<input type="hidden" name="jform[list4][]" value="0">
<input type="hidden" name="jform[list4][]" value="2">
</div>I haven't tested the code, maybe you can share some subform to make debugging easier
I added this to administrator/components/com_content/forms/article.xml

<fieldset name="showontest" label="SHOWONTEST">
<field
name="list1"
type="list"
label="LIST ENABLE"
default="0"
>
<option value="0">VALUE 0</option>
<option value="1">VALUE 1</option>
</field>
<field
name="text1"
type="text"
label="TEXT 1"
showon="list1:1"
/>
<field
name="list2"
type="list"
label="LIST DISABLE"
default="0"
readonly="true"
>
<option value="0">VALUE 0</option>
<option value="1">VALUE 1</option>
</field>
<field
name="text2"
type="text"
label="TEXT 2"
showon="list2:1"
/>
<field
name="list3"
type="list"
label="LIST ENABLE MULT"
multiple="true"
default="[0,2]"
>
<option value="0">VALUE 0</option>
<option value="1">VALUE 1</option>
<option value="2">VALUE 2</option>
</field>
<field
name="text3"
type="text"
label="TEXT 3"
showon="list3:1"
/>
<field
name="list4"
type="list"
label="LIST DISABLE MULT"
multiple="true"
default="[0,2]"
readonly="true"
>
<option value="0">VALUE 0</option>
<option value="1">VALUE 1</option>
<option value="2">VALUE 2</option>
</field>
<field
name="text4"
type="text"
label="TEXT 4"
showon="list4:1"
/>
</fieldset>
This pull request has been automatically rebased to 4.3-dev.
| Labels |
Added:
bug
?
|
||
| Title |
|
||||||
| Labels |
Added:
PR-4.3-dev
Removed: ? |
||
This pull request has been automatically rebased to 4.4-dev.
Could you make this PR ready so that we can test this during PBF?
| Title |
|
||||||
| Labels |
Added:
Small
PR-4.4-dev
Removed: PR-4.3-dev ? |
||||||
| Title |
|
||||||
I have tested this item ✅ successfully on 91bc2cd
Tested Successfully
I have tested this item ✅ successfully on 91bc2cd
| Status | Pending | ⇒ | Ready to Commit |
RTC
| Labels |
Added:
RTC
PBF
|
||
| Status | Ready to Commit | ⇒ | Fixed in Code Base |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-03-01 06:18:27 |
| Closed_By | ⇒ | laoneo |
Thanks!
@dgrammatiko Can you support me here? I have a problem when the multiple attr is set. You solved a similar problem with #35723. Thanks in advance.