New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.0] Problems with class attribut in Field Switcher #19943
Comments
@astridx there was some discussion about this in the other PRs. I think someone very brave needs to change the field to use the type attribute from the XML and also patch all the XMLs that have a switcher (that's the tricky part 😜) |
Actually, the type attribute would be wrong. At least the way the field currently works (with two different JLayouts). Using the type attribute would mean we create a completely new field for that switcher. |
@Bakual It should be a new field ideally. Reason being is the I agree that using a class to call the switcher is bad, however using the following is also bad:
Much better to separate it and use:
|
Happy to do the leg work of patching the xml when a decision is made |
With current code, the correct way to set the layout would be
That does work without any changes in the PHP side. However it doesn't solve the issue here (an own type doesn't solve it as well). The problem we have is that in J3 core uses button groups and in J4 we use switchers. If an extension now wants to work both in J3 and J4 and use the same UI which core uses, it isn't possible currently. As it is, the only option for now is to keep using button groups. Those are supposed to work both in J3 and J4. An extension can switch to using switchers only when they drop support for J3. |
closed as having Pull Request #19953 |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/19943 |
Steps to reproduce the issue
Create a field of type radio with the class switcher:
For example:
Expected result
The switcher should behave in Joomla 3 and Joomla 4 like expected. In Joomla 3 you need the classes btn-group btn-group-yesno and for Joomla 4 the class switcher is important.
Actual result
In Joomla 4 you do not see the green color if active.
Additional Informations
I think the problem is this line:
$type = str_replace('switcher switcher-', '', trim($class));
You can find this line here:
joomla-cms/layouts/joomla/form/field/radio/switcher.php
Line 67 in 4487099
The type of the field is set with the class attribute.
I changed this line in
and everything works fine. My changes make, that if the word switcher is in the values of the class attribute, the type is set to switcher. But I am sure that this is not that easy ....
The text was updated successfully, but these errors were encountered: