library/core/class.form.php
public function CheckBox($FieldName, $Label = '', $Attributes = FALSE) {
      $Value = ArrayValueI('value', $Attributes, true);
      $Attributes['value'] = $Value;

      if ($this->GetValue($FieldName) == $Value)
         $Attributes['checked'] = 'checked';
         
      // Show inline errors?
      $ShowErrors = ($this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults));
      
      // Add error class to input element
      if ($ShowErrors) 
         $this->AddErrorClass($Attributes);

      $Input = $this->Input($FieldName, 'checkbox', $Attributes);
      if ($Label != '') $Input = '<label for="' . ArrayValueI('id', $Attributes,
         $this->EscapeID($FieldName, FALSE)) . '" class="CheckBoxLabel"'.Attribute('title', GetValue('title', $Attributes)).'>' . $Input . ' ' .
          T($Label) . '</label>';
          
      // Append validation error message
      if ($ShowErrors && ArrayValueI('InlineErrors', $Attributes, TRUE))  
         $Return .= $this->InlineError($FieldName);

      return $Input;
   }
public function CheckBox($FieldName, $Label = '', $Attributes = FALSE) {
      $Value = ArrayValueI('value', $Attributes, true);
      $Attributes['value'] = $Value;

      if ($this->GetValue($FieldName) == $Value)
         $Attributes['checked'] = 'checked';
         
      // Show inline errors?
      $ShowErrors = ($this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults));
      
      // Add error class to input element
      if ($ShowErrors) 
         $this->AddErrorClass($Attributes);

      $Input = $this->Input($FieldName, 'checkbox', $Attributes);
      if ($Label != '') $Input = '<label for="' . ArrayValueI('id', $Attributes,
         $this->EscapeID($FieldName, FALSE)) . '" class="CheckBoxLabel"'.Attribute('title', GetValue('title', $Attributes)).'>' . $Input . ' ' .
          T($Label) . '</label>';
          
      // Append validation error message
      if ($ShowErrors && ArrayValueI('InlineErrors', $Attributes, TRUE))  
         $Return .= $this->InlineError($FieldName);

      return $Input;
   }
public function CheckBox ( $ FieldName , $ Label = '' , $ Attributes = FALSE ) { $ Value = ArrayValueI ( 'value' , $ Attributes , true ) ; $ Attributes [ 'value' ] = $ Value ; if ( $ this -> GetValue ( $ FieldName ) == $ Value ) $ Attributes [ 'checked' ] = 'checked' ; // Show inline errors? $ ShowErrors = ( $ this -> _InlineErrors && array_key_exists ( $ FieldName , $ this -> _ValidationResults ) ) ; // Add error class to input element if ( $ ShowErrors ) $ this -> AddErrorClass ( $ Attributes ) ; $ Input = $ this -> Input ( $ FieldName , 'checkbox' , $ Attributes ) ; if ( $ Label != '' ) $ Input = '<label for="' . ArrayValueI ( 'id' , $ Attributes , $ this -> EscapeID ( $ FieldName , FALSE ) ) . '" class="CheckBoxLabel"' . Attribute ( 'title' , GetValue ( 'title' , $ Attributes ) ) . '>' . $ Input . ' ' . T ( $ Label ) . '</label>' ; // Append validation error message if ( $ ShowErrors && ArrayValueI ( 'InlineErrors' , $ Attributes , TRUE ) ) $ Return .= $ this -> InlineError ( $ FieldName ) ; return $ Input ; }
Returns XHTML for a checkbox input element.

Cannot consider all checkbox values to be boolean. (2009-04-02 mosullivan)
Cannot assume checkboxes are stored in database as string 'TRUE'. (2010-07-28 loki_racer)

@param string $FieldName Name of the field that is being displayed/posted with this input.
It should related directly to a field name in $this->_DataArray.
@param string $Label Label to place next to the checkbox.
@param array $Attributes Associative array of attributes for the input. (e.g. onclick, class)\
Setting 'InlineErrors' to FALSE prevents error message even if $this->InlineErrors is enabled.
@return string
Returns XHTML for a checkbox input element .