library/core/class.form.php
public function CheckBoxList($FieldName, $DataSet, $ValueDataSet = NULL, $Attributes = FALSE) {
      // Never display individual inline errors for these CheckBoxes
      $Attributes['InlineErrors'] = FALSE;
      
      $Return = '';
      // If the form hasn't been posted back, use the provided $ValueDataSet
      if ($this->IsPostBack() === FALSE) {
         if ($ValueDataSet === NULL) {
            $CheckedValues = $this->GetValue($FieldName);
         } else {
            $CheckedValues = $ValueDataSet;
            if (is_object($ValueDataSet))
               $CheckedValues = ConsolidateArrayValuesByKey($ValueDataSet->ResultArray(), $FieldName);
         }
      } else {
         $CheckedValues = $this->GetFormValue($FieldName, array());
      }
      $i = 1;
      if (is_object($DataSet)) {
         $ValueField = ArrayValueI('ValueField', $Attributes, 'value');
         $TextField = ArrayValueI('TextField', $Attributes, 'text');
         foreach($DataSet->Result() as $Data) {
            $Instance = $Attributes;
            $Instance = RemoveKeyFromArray($Instance,
               array('TextField', 'ValueField'));
            $Instance['value'] = $Data->$ValueField;
            $Instance['id'] = $FieldName . $i;
            if (is_array($CheckedValues) && in_array($Data->$ValueField,
               $CheckedValues)) {
               $Instance['checked'] = 'checked';
            }

            $Return .= '<li>' . $this->CheckBox($FieldName . '[]',
               $Data->$TextField, $Instance) . "</li>\n";
            ++$i;
         }
      } elseif (is_array($DataSet)) {
         foreach($DataSet as $Text => $ID) {
            // Set attributes for this instance
            $Instance = $Attributes;
            $Instance = RemoveKeyFromArray($Instance, array('TextField', 'ValueField'));
            
            $Instance['id'] = $FieldName . $i;

            if (is_array($ID)) {
               $ValueField = ArrayValueI('ValueField', $Attributes, 'value');
               $TextField = ArrayValueI('TextField', $Attributes, 'text');
               $Text = GetValue($TextField, $ID, '');
               $ID = GetValue($ValueField, $ID, '');
            } else {
               

               if (is_numeric($Text))
                  $Text = $ID;
            }
            $Instance['value'] = $ID;
            
            if (is_array($CheckedValues) && in_array($ID, $CheckedValues)) {
               $Instance['checked'] = 'checked';
            }

            $Return .= '<li>' . $this->CheckBox($FieldName . '[]', $Text, $Instance) . "</li>\n";
            ++$i;
         }
      }
      
      return '<ul class="'.ConcatSep(' ', 'CheckBoxList', GetValue('listclass', $Attributes)).'">' . $Return . '</ul>';
   }
public function CheckBoxList($FieldName, $DataSet, $ValueDataSet = NULL, $Attributes = FALSE) {
      // Never display individual inline errors for these CheckBoxes
      $Attributes['InlineErrors'] = FALSE;
      
      $Return = '';
      // If the form hasn't been posted back, use the provided $ValueDataSet
      if ($this->IsPostBack() === FALSE) {
         if ($ValueDataSet === NULL) {
            $CheckedValues = $this->GetValue($FieldName);
         } else {
            $CheckedValues = $ValueDataSet;
            if (is_object($ValueDataSet))
               $CheckedValues = ConsolidateArrayValuesByKey($ValueDataSet->ResultArray(), $FieldName);
         }
      } else {
         $CheckedValues = $this->GetFormValue($FieldName, array());
      }
      $i = 1;
      if (is_object($DataSet)) {
         $ValueField = ArrayValueI('ValueField', $Attributes, 'value');
         $TextField = ArrayValueI('TextField', $Attributes, 'text');
         foreach($DataSet->Result() as $Data) {
            $Instance = $Attributes;
            $Instance = RemoveKeyFromArray($Instance,
               array('TextField', 'ValueField'));
            $Instance['value'] = $Data->$ValueField;
            $Instance['id'] = $FieldName . $i;
            if (is_array($CheckedValues) && in_array($Data->$ValueField,
               $CheckedValues)) {
               $Instance['checked'] = 'checked';
            }

            $Return .= '<li>' . $this->CheckBox($FieldName . '[]',
               $Data->$TextField, $Instance) . "</li>\n";
            ++$i;
         }
      } elseif (is_array($DataSet)) {
         foreach($DataSet as $Text => $ID) {
            // Set attributes for this instance
            $Instance = $Attributes;
            $Instance = RemoveKeyFromArray($Instance, array('TextField', 'ValueField'));
            
            $Instance['id'] = $FieldName . $i;

            if (is_array($ID)) {
               $ValueField = ArrayValueI('ValueField', $Attributes, 'value');
               $TextField = ArrayValueI('TextField', $Attributes, 'text');
               $Text = GetValue($TextField, $ID, '');
               $ID = GetValue($ValueField, $ID, '');
            } else {
               

               if (is_numeric($Text))
                  $Text = $ID;
            }
            $Instance['value'] = $ID;
            
            if (is_array($CheckedValues) && in_array($ID, $CheckedValues)) {
               $Instance['checked'] = 'checked';
            }

            $Return .= '<li>' . $this->CheckBox($FieldName . '[]', $Text, $Instance) . "</li>\n";
            ++$i;
         }
      }
      
      return '<ul class="'.ConcatSep(' ', 'CheckBoxList', GetValue('listclass', $Attributes)).'">' . $Return . '</ul>';
   }
public function CheckBoxList ( $ FieldName , $ DataSet , $ ValueDataSet = NULL , $ Attributes = FALSE ) { // Never display individual inline errors for these CheckBoxes $ Attributes [ 'InlineErrors' ] = FALSE ; $ Return = '' ; // If the form hasn't been posted back, use the provided $ValueDataSet if ( $ this -> IsPostBack ( ) === FALSE ) { if ( $ ValueDataSet === NULL ) { $ CheckedValues = $ this -> GetValue ( $ FieldName ) ; } else { $ CheckedValues = $ ValueDataSet ; if ( is_object ( $ ValueDataSet ) ) $ CheckedValues = ConsolidateArrayValuesByKey ( $ ValueDataSet -> ResultArray ( ) , $ FieldName ) ; } } else { $ CheckedValues = $ this -> GetFormValue ( $ FieldName , array ( ) ) ; } $ i = 1 ; if ( is_object ( $ DataSet ) ) { $ ValueField = ArrayValueI ( 'ValueField' , $ Attributes , 'value' ) ; $ TextField = ArrayValueI ( 'TextField' , $ Attributes , 'text' ) ; foreach ( $ DataSet -> Result ( ) as $ Data ) { $ Instance = $ Attributes ; $ Instance = RemoveKeyFromArray ( $ Instance , array ( 'TextField' , 'ValueField' ) ) ; $ Instance [ 'value' ] = $ Data -> $ ValueField ; $ Instance [ 'id' ] = $ FieldName . $ i ; if ( is_array ( $ CheckedValues ) && in_array ( $ Data -> $ ValueField , $ CheckedValues ) ) { $ Instance [ 'checked' ] = 'checked' ; } $ Return .= '<li>' . $ this -> CheckBox ( $ FieldName . '[]' , $ Data -> $ TextField , $ Instance ) . "</li>\n" ; ++ $ i ; } } elseif ( is_array ( $ DataSet ) ) { foreach ( $ DataSet as $ Text => $ ID ) { // Set attributes for this instance $ Instance = $ Attributes ; $ Instance = RemoveKeyFromArray ( $ Instance , array ( 'TextField' , 'ValueField' ) ) ; $ Instance [ 'id' ] = $ FieldName . $ i ; if ( is_array ( $ ID ) ) { $ ValueField = ArrayValueI ( 'ValueField' , $ Attributes , 'value' ) ; $ TextField = ArrayValueI ( 'TextField' , $ Attributes , 'text' ) ; $ Text = GetValue ( $ TextField , $ ID , '' ) ; $ ID = GetValue ( $ ValueField , $ ID , '' ) ; } else { if ( is_numeric ( $ Text ) ) $ Text = $ ID ; } $ Instance [ 'value' ] = $ ID ; if ( is_array ( $ CheckedValues ) && in_array ( $ ID , $ CheckedValues ) ) { $ Instance [ 'checked' ] = 'checked' ; } $ Return .= '<li>' . $ this -> CheckBox ( $ FieldName . '[]' , $ Text , $ Instance ) . "</li>\n" ; ++ $ i ; } } return '<ul class="' . ConcatSep ( ' ' , 'CheckBoxList' , GetValue ( 'listclass' , $ Attributes ) ) . '">' . $ Return . '</ul>' ; }
Returns the XHTML for a list of checkboxes.

@param string $FieldName Name of the field being posted with this input.

@param mixed $DataSet Data to fill the checkbox list. Either an associative
array or a database dataset. ex: RoleID, Name from GDN_Role.

@param mixed $ValueDataSet Values to be pre-checked in $DataSet. Either an associative array
or a database dataset. ex: RoleID from GDN_UserRole for a single user.

@param array $Attributes  An associative array of attributes for the select. Here is a list of
"special" attributes and their default values:
Attribute   Options                        Default
------------------------------------------------------------------------
ValueField  The name of the field in       'value'
$DataSet that contains the
option values.
TextField   The name of the field in       'text'
$DataSet that contains the
option text.

@return string
Returns the XHTML for a list of checkboxes .