?
avatar htmgarcia
htmgarcia
7 May 2018

Steps to reproduce the issue

If you are adding a radio parameter using the switcher class (in this case for a template through the file templateDetails.xml)

<field
    name="something"
    type="radio"
    class="switcher"
    default="0"
    label="Something">
        <option value="1">Yes</option>
	<option value="0">No</option>
</field>

Expected result

The switcher should be in gray color when the default value is 0 ("No")
The switcher should be in green color when the default value is 1 ("Yes")

Actual result

The switcher is in green color when the default value is 0 ("No")
screen shot 2018-05-07 at 4 24 55 pm

The switcher is in gray color when the default value is 1 ("Yes")
screen shot 2018-05-07 at 4 25 28 pm

System information (as much as possible)

Chrome Version 66.0.3359.139 (Official Build) (64-bit)
MacOS High Sierra 10.13.4

Additional comments

It seems that the order of the options would make the switcher to works fine:

<option value="0">No</option>
<option value="1">Yes</option>

In the other side, if the options are listed with "1" as first, is when doesn't work:

<option value="1">Yes</option>
<option value="0">No</option>
avatar htmgarcia htmgarcia - open - 7 May 2018
avatar joomla-cms-bot joomla-cms-bot - change - 7 May 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 7 May 2018
avatar htmgarcia htmgarcia - change - 7 May 2018
Title
Switcher parameter style works odd
Switcher parameter style works odd (Joomla 4)
avatar htmgarcia htmgarcia - edited - 7 May 2018
avatar dgrammatiko
dgrammatiko - comment - 7 May 2018

I will try to fix this in joomla/40-backend-template#395

avatar htmgarcia
htmgarcia - comment - 7 May 2018

Thanks @dgrammatiko !

avatar htmgarcia
htmgarcia - comment - 7 May 2018

Closing. This issue was already reported joomla/40-backend-template#395 (comment)

avatar htmgarcia htmgarcia - change - 7 May 2018
Status New Closed
Closed_Date 0000-00-00 00:00:00 2018-05-07 21:43:49
Closed_By htmgarcia
avatar htmgarcia htmgarcia - close - 7 May 2018
avatar C-Lodder
C-Lodder - comment - 9 May 2018

The normal approach for the Switcher would be (note the order of the options)

<option value="0">No</option>
<option value="1">Yes</option>

This would result in: No (grey) and Yes (green).

If you don't want "Yes" to be green, or is not the recommended setting, you can add a class to the XML field, like so:

<field
    type="radio"
    class="switcher switcher-danger"

You cannot "patch" this simply because it may not always be the case where the user uses the values 0 and 1 or the text No and Yes. They may very well go with:

<option value="foo">Apples</option>
<option value="bar">Pears</option>

Add a Comment

Login with GitHub to post a comment