{"action":"closed","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/19943","repository_url":"https://api.github.com/repos/joomla/joomla-cms","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19943/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19943/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19943/events","html_url":"https://github.com/joomla/joomla-cms/issues/19943","id":306534313,"number":19943,"title":"[4.0] Problems with class attribut in Field Switcher","user":{"login":"astridx","id":9974686,"avatar_url":"https://avatars0.githubusercontent.com/u/9974686?v=4","gravatar_id":"","url":"https://api.github.com/users/astridx","html_url":"https://github.com/astridx","followers_url":"https://api.github.com/users/astridx/followers","following_url":"https://api.github.com/users/astridx/following{/other_user}","gists_url":"https://api.github.com/users/astridx/gists{/gist_id}","starred_url":"https://api.github.com/users/astridx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astridx/subscriptions","organizations_url":"https://api.github.com/users/astridx/orgs","repos_url":"https://api.github.com/users/astridx/repos","events_url":"https://api.github.com/users/astridx/events{/privacy}","received_events_url":"https://api.github.com/users/astridx/received_events","type":"User","site_admin":false},"labels":[{"id":138443932,"url":"https://api.github.com/repos/joomla/joomla-cms/labels/No%20Code%20Attached%20Yet","name":"No Code Attached Yet","color":"ededed","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-03-19T16:24:07Z","updated_at":"2018-03-20T19:50:48Z","closed_at":"2018-03-20T19:50:47Z","author_association":"CONTRIBUTOR","body":"### Steps to reproduce the issue\r\nCreate a field of type radio with the class switcher:\r\n\r\nFor example:\r\n```\r\n\t\t<field\r\n\t\t\tname=\"show_title\"\r\n\t\t\ttype=\"radio\"\r\n\t\t\tlabel=\"JGLOBAL_SHOW_TITLE_LABEL\"\r\n\t\t\tclass=\"switcher btn-group btn-group-yesno \"\r\n\t\t\tdefault=\"1\"\r\n\t\t\t>\r\n\t\t\t<option value=\"0\">JHIDE</option>\r\n\t\t\t<option value=\"1\">JSHOW</option>\r\n\t\t</field>\r\n```\r\n\r\n\r\n### Expected result\r\nThe switcher should behave in Joomla 3 and Joomla 4 like expected. In Joomla 3 you need the classes <tt>btn-group btn-group-yesno </tt> and for Joomla 4 the class <tt>switcher</tt> is important.\r\n\r\n\r\n### Actual result\r\nIn Joomla 4 you do not see the green color if active.\r\n\r\n### Additional Informations\r\nI think the problem is this line:\r\n$type = str_replace('switcher switcher-', '', trim($class));\r\n\r\nYou can find this line here:\r\nhttps://github.com/joomla/joomla-cms/blob/44870990a55c188d64dbd9407f2231f765769689/layouts/joomla/form/field/radio/switcher.php#L67\r\n\r\nThe type of the field is set with the class attribute.\r\n\r\nI changed this line in \r\n\r\n```\r\nif (strpos($type, 'switcher') !== false){\r\n\t$type = 'switcher';\r\n}\r\n```\r\nand everything works fine. My changes make, that if the word switcher is in the values of the class attribute, the type is set to <tt>switcher</tt>. But I am sure that this is not that easy ...."}}
{"actor":{"display_login":"joomla-cms-bot"}}