mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 21:57:51 +02:00
Fix for unchecked-checkbox value submission.
This commit is contained in:
@@ -2353,7 +2353,7 @@ class e_form
|
|||||||
'size' => $options['switch'],
|
'size' => $options['switch'],
|
||||||
'onText' => $options_on['label'],
|
'onText' => $options_on['label'],
|
||||||
'offText' => $options_off['label'],
|
'offText' => $options_off['label'],
|
||||||
|
'inverse' => !empty($options['inverse']),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2362,12 +2362,12 @@ class e_form
|
|||||||
$js_options[$name]['wrapperClass'] = 'wrapper form-control';
|
$js_options[$name]['wrapperClass'] = 'wrapper form-control';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
e107::library('load', 'bootstrap.switch');
|
e107::library('load', 'bootstrap.switch');
|
||||||
e107::js('settings', array('bsSwitch' => $js_options));
|
e107::js('settings', array('bsSwitch' => $js_options));
|
||||||
e107::js('footer', '{e_WEB}js/bootstrap.switch.init.js', 'jquery', 5);
|
e107::js('footer', '{e_WEB}js/bootstrap.switch.init.js', 'jquery', 5);
|
||||||
|
|
||||||
$text = $this->checkbox($name, 1, $checked_enabled);
|
$text = $this->hidden($name, (int) $checked_enabled);
|
||||||
|
$text .= $this->checkbox($name, 1, $checked_enabled);
|
||||||
}
|
}
|
||||||
elseif(!empty($options['inverse'])) // Same as 'writeParms'=>'reverse=1&enabled=LAN_DISABLED&disabled=LAN_ENABLED'
|
elseif(!empty($options['inverse'])) // Same as 'writeParms'=>'reverse=1&enabled=LAN_DISABLED&disabled=LAN_ENABLED'
|
||||||
{
|
{
|
||||||
|
24
e107_web/js/bootstrap.switch.init.js
vendored
24
e107_web/js/bootstrap.switch.init.js
vendored
@@ -17,6 +17,8 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
|||||||
$.each(settings.bsSwitch, function (name, options)
|
$.each(settings.bsSwitch, function (name, options)
|
||||||
{
|
{
|
||||||
$('input[name="' + name + '"]', context).once('bootstrap-switch-init').each(function ()
|
$('input[name="' + name + '"]', context).once('bootstrap-switch-init').each(function ()
|
||||||
|
{
|
||||||
|
if($(this).attr('type') != 'hidden')
|
||||||
{
|
{
|
||||||
$(this).bootstrapSwitch({
|
$(this).bootstrapSwitch({
|
||||||
size: options.size || 'mini',
|
size: options.size || 'mini',
|
||||||
@@ -24,6 +26,28 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
|||||||
offText: options.offText || null,
|
offText: options.offText || null,
|
||||||
wrapperClass: options.wrapperClass || null
|
wrapperClass: options.wrapperClass || null
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(this).on('switchChange.bootstrapSwitch', function (event, state) {
|
||||||
|
var name = $(this).attr('name');
|
||||||
|
var checked = true;
|
||||||
|
|
||||||
|
if(state === false)
|
||||||
|
{
|
||||||
|
checked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var value = checked ? 1 : 0;
|
||||||
|
|
||||||
|
if(options.inverse)
|
||||||
|
{
|
||||||
|
// value = checked ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('input[type="hidden"][name="' + name + '"]').val(value);
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user