Source for file jFormsControlCheckboxes.class.php

Documentation is available at jFormsControlCheckboxes.class.php

  1. <?php
  2. /**
  3. * @package     jelix
  4. * @subpackage  forms
  5. * @author      Laurent Jouanneau
  6. * @contributor
  7. * @copyright   2006-2008 Laurent Jouanneau
  8. * @link        http://www.jelix.org
  9. * @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
  10. */
  11.  
  12.  
  13. /**
  14.  * Checkboxes control (contains several checkboxes)
  15.  * @package     jelix
  16.  * @subpackage  forms
  17.  */
  18. class jFormsControlCheckboxes extends jFormsControlDatasource {
  19.     public $type="checkboxes";
  20.  
  21.     function isContainer(){
  22.         return true;
  23.     }
  24.  
  25.     function check(){
  26.         $value = $this->container->data[$this->ref];
  27.         if(is_array($value)){
  28.             if(count($value) == 0 && $this->required){
  29.                 return $this->container->errors[$this->ref] = jForms::ERRDATA_REQUIRED;
  30.             }
  31.         }else{
  32.             if(trim($value) == ''){
  33.                 if($this->required)
  34.                     return $this->container->errors[$this->ref] = jForms::ERRDATA_REQUIRED;
  35.             }else{
  36.                 return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID;
  37.             }
  38.         }
  39.         return null;
  40.     }
  41. }

Documentation generated on Thu, 22 Mar 2012 22:15:55 +0100 by phpDocumentor 1.4.3