Example #1
0
 function __construct($elemname, $currentvalue = '', $prompttext = '', $helptext = '', $jsvalidation = '', $failvalidationmsg = '', $canbeempty = true, $maxchars = 0, $disable = false, $label = 'Enable', $disabled_value = 'DEFAULT', $check_enables = 'true')
 {
     // call parent class contructor
     if ($disable) {
         $currentvalue = $disabled_value;
     }
     parent::__construct($elemname, $currentvalue, $prompttext, $helptext, $jsvalidation, $failvalidationmsg, $canbeempty, $maxchars, $disable);
     $cb_state = $disable && $check_enables || !$disable && !$check_enables ? '' : ' CHECKED';
     $OnClickClass = "class=\"input_checkbox_toggle_" . ($check_enables ? 'false' : 'true') . "\"";
     $cbid = $this->_elemname . '_cb';
     $this->html_input .= "<input type=\"checkbox\" name=\"{$cbid}\" id=\"{$cbid}\" data-disabled=\"{$disabled_value}\" {$OnClickClass}{$cb_state}> <label for=\"{$cbid}\">{$label}</label>\n";
 }
Example #2
0
 function __construct($elemname, $currentvalue = '', $prompttext = '', $helptext = '', $jsvalidation = '', $failvalidationmsg = '', $canbeempty = true, $maxchars = 0, $disable = false, $cblabel = 'Enable', $disabled_value = 'DEFAULT', $check_enables = 'true', $cbdisable = false, $class = '', $cbclass = '')
 {
     if (is_array($elemname)) {
         extract($elemname);
     }
     // call parent class contructor
     if ($disable) {
         $currentvalue = $disabled_value;
     }
     parent::__construct($elemname, $currentvalue, $prompttext, $helptext, $jsvalidation, $failvalidationmsg, $canbeempty, $maxchars, $disable, true, $class);
     $cb_disable = $cbdisable ? 'disabled' : '';
     if (!isset($cbchecked)) {
         if (is_string($check_enables)) {
             $check_enables = $check_enables == "true" ? true : false;
         }
         $cb_state = $disable && $check_enables || !$disable && !$check_enables ? '' : ' CHECKED';
     } else {
         $cb_state = $cbchecked ? 'CHECKED' : '';
     }
     if (is_bool($check_enables)) {
         $check_enables = $check_enables ? "true" : "false";
     }
     $cbid = !empty($cbelemname) ? $cbelemname : $this->_elemname . '_cb';
     $this->html_input .= "<span class=\"input-group-addon\"><input type=\"checkbox\" name=\"{$cbid}\" id=\"{$cbid}\" data-disabled=\"{$disabled_value}\" data-enables=\"{$check_enables}\" class=\"{$cbclass}\" value=\"checked\" {$cb_state} {$cb_disable}> <label for=\"{$cbid}\">{$cblabel}</label></span></div>";
     $this->html_input .= "<script>\$('#{$cbid}').change(function() {\n\t\t\tvar state = (\$(this).is(':checked') ? true : false),\n\t\t\t\t\tdisable = ({$check_enables} !== state),\n\t\t\t\t\tval = \$('#{$elemname}').val();\n\t\t\tif(disable) {\n\t\t\t\t\$('#{$elemname}').data('orig', val);\n\t\t\t\t\$('#{$elemname}').val(\$(this).data('disabled'));\n\t\t\t} else {\n\t\t\t\t\$('#{$elemname}').val(\$('#{$elemname}').data('orig'))\n\t\t\t}\n\t\t\t\$('#{$elemname}').prop('disabled', disable);\n\t\t})</script>";
     $this->type = "textbox_check";
 }