Skip to content

Conversation

sebastian-marinescu
Copy link
Contributor

Adds support for radiogroup-settings. See #202 for details.

Resolves #202
But needs to wait for modxcms/revolution#16404 to be accepted.

@sebastian-marinescu
Copy link
Contributor Author

sebastian-marinescu commented Feb 27, 2023

Sneak-Preview:

image

How it would be used:

image

@Mark-H
Copy link
Member

Mark-H commented Nov 7, 2023

This is cool. As far as that core fix goes, do we have to implement some kind of version check to prevent radiogroups from being used on <3.0.4?

@sebastian-marinescu
Copy link
Contributor Author

Probably a good idea! And also we should do the same for the 2.x branch, when modxcms/revolution#16467 is accepted.

That version-check would need to go into this if-clause:

if ((field.xtype === 'radiogroup') || (field.xtype === 'xradiogroup')) {

Correct?

Do you know, if we have the MODX-version information there available?

@sebastian-marinescu
Copy link
Contributor Author

sebastian-marinescu commented Mar 19, 2025

I've added a version compare function at the top of the file, so I can here more conveniently compare the versions:

var hasRadioGroupCompatibleVersion = false,
minModx2RGVersion = "2.8.7",
minModx3RGVersion = "3.0.4";
if (MODx && MODx.config && MODx.config.version) {
var modxVersion = MODx.config.version.substring(0, MODx.config.version.length - 3),
modxVersionMajor = parseInt(modxVersion.substring(0, 1));
if (modxVersionMajor === 2) {
hasRadioGroupCompatibleVersion = versionCompare(modxVersion, minModx2RGVersion) !== -1;
} else if (modxVersionMajor === 3) {
hasRadioGroupCompatibleVersion = versionCompare(modxVersion, minModx3RGVersion) !== -1;
} else if (modxVersionMajor > 3) {
hasRadioGroupCompatibleVersion = true;
}
}

Even though the documentation says there should be a MODx.version object - I haven't found it. But I have found the MODX version inside of MODx.config.version.

If an incompatible version is detected, I still had to work around the errors being thrown. So I hacked around them:

var extMC = new Ext.util.MixedCollection();
field.items = [{
boxLabel: 'Feature not available in your MODX-version, please update to at least version ' + (modxVersionMajor === 2 ? minModx2RGVersion : minModx3RGVersion),
inputValue: 0,
checked: true,
name: field.name
}];
extMC.addAll(field.items);
field.items = extMC;
field.items[0] = extMC.items;

I have just tested it in a 2.8.6 and a 2.8.8 setup. Still needs testing in v3.

Would love to enable these new CC xtypes (yours especially) as soon as possible ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature-Request: Radio-Button Settings

2 participants