J4 Issue ?
avatar astridx
astridx
24 Jun 2018

Steps to reproduce the issue

Open global configuration and see outer html of the field "Search Engine Friendly URLs"


<joomla-field-switcher id="jform_sef" off-text="No" on-text="Yes" type="success">
<span class="switcher active has-success" tabindex="0" aria-checked="true" role="switch" aria-label="Yes"><input id="jform_sef0" name="jform[sef]" value="0" tabindex="-1" class="valid form-control-success" aria-invalid="false" type="radio"><input id="jform_sef1" name="jform[sef]" value="1" class="valid active form-control-success" tabindex="-1" checked="" aria-invalid="false" type="radio"><span class="switch"></span></span><span class="switcher-labels"><span class="switcher-label-0">No</span><span class="switcher-label-1 active">Yes</span></span></joomla-field-switcher>

Open /administrator/components/com_config/forms/application.xml

and change the field (insert disabled="true")

		<field
			name="sef"
			type="radio"
			label="COM_CONFIG_FIELD_SEF_URL_LABEL"
			class="switcher"
			default="1"
			filter="boolean"
			>
			<option value="0">JNO</option>
			<option value="1">JYES</option>
		</field>

to

		<field
			name="sef"
			type="radio"
			label="COM_CONFIG_FIELD_SEF_URL_LABEL"
			class="switcher"
			disabled="true"
			default="1"
			filter="boolean"
			>
			<option value="0">JNO</option>
			<option value="1">JYES</option>
		</field>

Open again global configuration and see outer html of the field "Search Engine Friendly URLs". Now the text disabled="" is added.

<joomla-field-switcher id="jform_sef" off-text="No" on-text="Yes" disabled="" type="success">
<span class="switcher active has-success" tabindex="0" aria-checked="true" role="switch" aria-label="Yes"><input id="jform_sef0" name="jform[sef]" value="0" tabindex="-1" class="valid form-control-success" aria-invalid="false" type="radio"><input id="jform_sef1" name="jform[sef]" value="1" class="valid active form-control-success" tabindex="-1" checked="" aria-invalid="false" type="radio"><span class="switch"></span></span><span class="switcher-labels"><span class="switcher-label-0">No</span><span class="switcher-label-1 active">Yes</span></span></joomla-field-switcher>

Expected result

The field "Search Engine Friendly URLs" is disabled.

Actual result

Nothing changed. The field works as before.

System information (as much as possible)

Current 4.0-dev branch on ubuntu

Additional comments

My guess:
In the layout file
/layouts/joomla/form/field/radio/switcher.php
disabled is added. But the value of the attributes must be set. Also in the file
/media/system/webcomponents/js/joomla-field-switcher.js
this attribute must be implemented.

avatar astridx astridx - open - 24 Jun 2018
avatar joomla-cms-bot joomla-cms-bot - change - 24 Jun 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 24 Jun 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 24 Jun 2018
Category Administration
avatar franz-wohlkoenig franz-wohlkoenig - change - 24 Jun 2018
Status New Discussion
avatar brianteeman brianteeman - change - 25 Jun 2018
Labels Added: J4 Issue
avatar brianteeman brianteeman - labeled - 25 Jun 2018
avatar Anu1601CS
Anu1601CS - comment - 26 Jun 2018

@C-Lodder Any idea ?

avatar C-Lodder
C-Lodder - comment - 27 Jun 2018

@Anu1601CS yes I see the issue.

Remove this block of code: https://github.com/joomla/joomla-cms/blob/4.0-dev/layouts/joomla/form/field/radio/switcher.php#L82-L85


Then replace this line, with:

$disabled = !empty($disabled) ? 'disabled' : '';
$attributes = array_filter(array($checked, $active, null, $onchange, $onclick, disabled));

That will prevent you from being able to click the switcher.


You then of course need to prevent spacebar and enter buttons from triggering a switch.

To do that, replace this function with:

keyEvents(event) {
	if (event.keyCode === KEYCODE.ENTER || event.keyCode === KEYCODE.SPACE) {
		event.preventDefault();
		if (!this.inputs[1].disabled) {
			this.toggle.bind(this)();
		}
	}
}

Not tested but should work.

avatar brianteeman brianteeman - change - 29 Jun 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-06-29 09:49:49
Closed_By brianteeman
avatar brianteeman
brianteeman - comment - 29 Jun 2018

Closed see #20929

avatar brianteeman brianteeman - close - 29 Jun 2018

Add a Comment

Login with GitHub to post a comment