mirror of
https://github.com/e107inc/e107.git
synced 2025-08-15 11:04:18 +02:00
Switch fix
This commit is contained in:
@@ -2251,7 +2251,7 @@ class e_form
|
||||
|
||||
if(empty($options['id']))
|
||||
{
|
||||
$options['id'] = '';
|
||||
unset($options['id']);
|
||||
}
|
||||
// $options['class'] = 'inline';
|
||||
$text = "";
|
||||
@@ -2341,7 +2341,7 @@ class e_form
|
||||
|
||||
if(!empty($options['switch']))
|
||||
{
|
||||
return $this->switch($name,$checked_enabled, array('on'=>$options_on['label'],'off'=>$options_off['label']),$options);
|
||||
return $this->flipswitch($name,$checked_enabled, array('on'=>$options_on['label'],'off'=>$options_off['label']),$options);
|
||||
}
|
||||
elseif(!empty($options['inverse'])) // Same as 'writeParms'=>'reverse=1&enabled=LAN_DISABLED&disabled=LAN_ENABLED'
|
||||
{
|
||||
@@ -2368,7 +2368,7 @@ class e_form
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
public function switch($name, $checked_enabled = false, $labels=array('on' =>LAN_ON, 'off' =>LAN_OFF), $options = array())
|
||||
public function flipswitch($name, $checked_enabled = false, $labels=array('on' =>LAN_ON, 'off' =>LAN_OFF), $options = array())
|
||||
{
|
||||
|
||||
if(!empty($options['inverse']))
|
||||
@@ -2385,9 +2385,11 @@ class e_form
|
||||
|
||||
}
|
||||
|
||||
$switchName = $name.'__switch';
|
||||
|
||||
$js_options = array(
|
||||
// Each form element has its own options.
|
||||
$name => array(
|
||||
$switchName => array(
|
||||
'size' => $options['switch'],
|
||||
'onText' => $labels['on'],
|
||||
'offText' => $labels['off'],
|
||||
@@ -2406,7 +2408,7 @@ class e_form
|
||||
e107::js('footer', '{e_WEB}js/bootstrap.switch.init.js', 'jquery', 5);
|
||||
|
||||
$text = $this->hidden($name, (int) $checked_enabled);
|
||||
$text .= $this->checkbox($name, $checked_enabled, $checked_enabled);
|
||||
$text .= $this->checkbox($switchName, (int) $checked_enabled, $checked_enabled);
|
||||
|
||||
return $text;
|
||||
}
|
||||
@@ -2862,6 +2864,7 @@ class e_form
|
||||
function hidden($name, $value, $options = array())
|
||||
{
|
||||
$options = $this->format_options('hidden', $name, $options);
|
||||
|
||||
return "<input type='hidden' name='{$name}' value='{$value}'".$this->get_attributes($options, $name, $value)." />";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user