[4.0] Add "disabled" attribute to switcher#28356
Conversation
|
For the CSS side, the div containing the switcher has now an additional class when disabled. So it should be possible to target the disabled switchers with |
|
Readonly and disabled attributes are not the same. Values of disabled inputs are not submitted to the server. When readonly is used, selected radio should not be disabled. |
|
The thing is, there is no readonly attribute for radio elements. See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly. |
|
We can emulate readonly behavior by disabling all inputs except currently selected. Not sure how accessible that is though. @brianteeman any thoughts? |
|
@SharkyKZ Why do you want to emulate readonly? The readonly attribute doesn't make sense for radios, that's why it doesn't exist. There is no point in emulating it. |
|
Treating readonly and disabled the same is no good. We need to have the selected value submitted when readonly is used. It's not a matter of whether HTML element supports it or not, it's about how we implement the functionality in our fields. |
|
can someone tell me the use case for this |
|
Not allowing to change the value after the form was submitted for the first time. Or having a field disabled until another field has been filled in. |
|
As said, The dev using a readonly/disabled element has to take care of this on PHP side. You couldn't trust the submitted value anyway as the user could remove the disabled/readonly attribute in the browser. |
|
I have tested this item ✅ successfully on 87f2daa This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28356. |
|
I think this implementation is user-friendly. The normal user does not know that there is no @brianteeman Just as for the button, there are also use cases for the switch. You want to show that it is an option, but that it is deactivated with the current settings. It only bothered me that the appearance does not change. It looks like a mistake. That's why I added a PR here. For my test I added
to a switch in the file I tested also with
I tested also with the from me applied change. It looks like this: |
Switcher - add opacity if disabled
Merged. Thanks for the help! |
|
I have tested this item ✅ successfully on d39e43e This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28356. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28356. |
|
Setting back to Pending as there has only been one successful test. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28356. |
@jwaisner It's two tests. One from Quy and one from Astridx |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28356. |
|
Merged thanks @Bakual & testers 👍 |

Pull Request for Issue #27760 .
Summary of Changes
Adds the
disabledattribute to the switcher fields if in the XML eitherreadonlyordisabledis set.Since
readonlyisn't a valid attribute for radios (which technically a switcher still is), I just adddisabledin that case.I haven't touched CSS as I leave that to people who have a clue about design.
Imho it should be made visible somehow that the field is disabled.
Testing Instructions
See Issue #27760
Expected result
"Locked" Switcher
Actual result
Switcher can be toggled
Documentation Changes Required
None