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

Source for file form_field_integer.class.php

Documentation is available at form_field_integer.class.php

  1. <?php
  2. // *** Tangra (Application Framework and Tools for PHP)
  3. //  $Id$
  4. //
  5.  
  6. /**
  7.  * Contains class Form_Field_Integer
  8.  *
  9.  * @package tangra_lib
  10.  * @subpackage form
  11.  */
  12.  
  13. /**
  14.  *
  15.  */
  16. require_once(TANGRA_MAIN_DIR.'form/fields/number/form_field_number.class.php');
  17.  
  18.  
  19. /**
  20.  * Represents text field that accepts integer values
  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 Maximaum length of the text. Default is 100
  31.      * @param integer $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_an_integer');
  37.     }
  38.  
  39.  
  40.     /**
  41.      * Performs basic check for validity
  42.      *
  43.      * @return boolean 
  44.      * @internal
  45.      */
  46.     public function basic_check({
  47.         $has_errors parent::basic_check();
  48.  
  49.         if (!$has_errors{
  50.             if ($this->get_html_value(!= NULL and $this->get_html_value(!= ''{
  51.                 if (strpos($this->get_html_value()'.'!== false{
  52.                     $this->set_error('not_an_integer');
  53.                     $has_errors true;
  54.                 }
  55.             }
  56.         }
  57.  
  58.         return $has_errors;
  59.     }
  60. }