tangra logo
   
[ class tree: tangra_lib ] [ index: tangra_lib ] [ all elements ]
 

Source for file form_field_number.class.php

Documentation is available at form_field_number.class.php

  1. <?php
  2. // *** Tangra (Application Framework and Tools for PHP)
  3. //  $Id$
  4. //
  5.  
  6. /**
  7.  * Contains class Form_Field_Number
  8.  *
  9.  * @package tangra_lib
  10.  * @subpackage form
  11.  */
  12.  
  13. /**
  14.  *
  15.  */
  16. require_once(TANGRA_MAIN_DIR.'form/fields/text/form_field_text.class.php');
  17.  
  18.  
  19. /**
  20.  * Represents text field that accepts number
  21.  *
  22.  * @package tangra_lib
  23.  * @subpackage form
  24.  */
  25.     /**
  26.      * Constructor
  27.      *
  28.      * @param string $name Name of the field
  29.      * @param boolean $required Is field required. Default is false
  30.      * @param integer $maxlength Maximum length of the text. Default is 100
  31.      * @param string $value Default value.
  32.      */
  33.     function __construct($name$required false$maxlength 100$value NULL{
  34.         parent::__construct($name$required$maxlength$value);
  35.  
  36.         $this->add_potential_error('not_a_number');
  37.     }
  38.  
  39.     /**
  40.      * Performs basic check for validity
  41.      *
  42.      * @return boolean 
  43.      * @internal
  44.      */
  45.     public function basic_check({
  46.         $has_errors parent::basic_check();
  47.  
  48.         if (!$has_errors{
  49.             if ($this->get_html_value(!= NULL and $this->get_html_value(!= ''{
  50.                 if (!is_numeric($this->get_html_value())) {
  51.                     $this->set_error('not_a_number');
  52.                     $has_errors true;
  53.                 }
  54.             }
  55.         }
  56.  
  57.         return $has_errors;
  58.     }
  59. }