Source for file jFormsControlListbox.class.php

Documentation is available at jFormsControlListbox.class.php

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

Documentation generated on Thu, 19 Sep 2013 00:05:10 +0200 by phpDocumentor 1.4.3