Skip to content

Commit fbee00d

Browse files
committed
Attempt adding a multi checkbox field #143
1 parent 9e6db4b commit fbee00d

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

assets/components/clientconfig/js/mgr/sections/home.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,30 @@ Ext.extend(ClientConfig.page.Home,MODx.Component,{
128128
field.value = 1;
129129
field.checked = (value.value);
130130
}
131+
if (field.xtype === 'multi-checkbox') {
132+
field.xtype = 'checkboxgroup';
133+
field.columns = 1;
134+
field.items = [{xtype: 'checkbox', boxLabel: 'foo', 'name': 'foo'}];
135+
136+
var options = value.options.split('||');
137+
Ext.each(options, function(option, index) {
138+
option = option.split('==');
139+
if (option[1]) {
140+
field.items.push({
141+
boxLabel: option[0],
142+
value: option[1],
143+
name: field.name + '[]'
144+
})
145+
} else {
146+
field.items.push({
147+
boxLabel: option[0],
148+
value: option[0],
149+
name: field.name + '[]'
150+
})
151+
}
152+
});
153+
console.log(field);
154+
}
131155

132156
if (field.xtype == 'datefield') {
133157
field.format = MODx.config.manager_date_format;

assets/components/clientconfig/js/mgr/widgets/combos.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ ClientConfig.combo.FieldTypes = function(config) {
4444
['colorpickerfield', _('clientconfig.xtype.colorpalette')],
4545
['email', _('clientconfig.xtype.email')],
4646
['xcheckbox', _('clientconfig.xtype.xcheckbox')],
47+
['multi-checkbox', _('clientconfig.xtype.multi-checkbox')],
4748
['datefield', _('clientconfig.xtype.datefield')],
4849
['timefield', _('clientconfig.xtype.timefield')],
4950
['password', _('clientconfig.xtype.password')],

assets/components/clientconfig/js/mgr/widgets/window.settings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ClientConfig.window.Setting = function(config) {
7171
anchor: '100%',
7272
listeners: {
7373
select: {fn: function(field, record) {
74-
if (record.data.xtype == 'modx-combo') {
74+
if (['modx-combo', 'multi-checkbox'].indexOf(record.data.xtype) !== -1) {
7575
Ext.getCmp(config.id + '-options').show();
7676
Ext.getCmp(config.id + '-process_options').show();
7777
} else {
@@ -97,7 +97,7 @@ ClientConfig.window.Setting = function(config) {
9797
fieldLabel: _('clientconfig.options'),
9898
description: _('clientconfig.options.desc'),
9999
anchor: '100%',
100-
hidden: (config.record && (config.record.xtype === 'modx-combo')) ? false : true
100+
hidden: (config.record && (['modx-combo', 'multi-checkbox'].indexOf(config.record.xtype) !== -1)) ? false : true
101101
},{
102102
xtype: 'checkbox',
103103
id: config.id + '-process_options',

core/components/clientconfig/controllers/home.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function process(array $scriptProperties = array()) {
4141
$googleFontsApiKey = $this->modx->getOption('clientconfig.google_fonts_api_key', null, '');
4242
$sa['xtype'] = empty($googleFontsApiKey) ? 'textfield' : $sa['xtype'];
4343
}
44-
elseif ($sa['xtype'] === 'modx-combo' && $setting->get('process_options')) {
44+
elseif ($setting->get('process_options') && in_array($sa['xtype'], ['modx-combo', 'multi-checkbox'], true)) {
4545
$inputOpts = $setting->get('options');
4646
$this->modx->getParser();
4747
$this->modx->parser->processElementTags('', $inputOpts, true, true);

core/components/clientconfig/lexicon/en/default.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,4 @@
113113
$_lang['clientconfig.xtype.line'] = 'Line (divider)';
114114
$_lang['clientconfig.xtype.code'] = 'Code (requires Ace editor installed)';
115115
$_lang['clientconfig.xtype.email'] = 'Email';
116+
$_lang['clientconfig.xtype.multi-checkbox'] = 'Multiple checkboxes';

0 commit comments

Comments
 (0)