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

Source for file form_field_money_positive.class.php

Documentation is available at form_field_money_positive.class.php

  1. <?php
  2. // *** Tangra (Application Framework and Tools for PHP)
  3. //  $Id$
  4. //
  5.  
  6. /**
  7.  * Contains class Form_Field_Money_Positive
  8.  *
  9.  * @package tangra_lib
  10.  * @subpackage form
  11.  */
  12.  
  13. /**
  14.  *
  15.  */
  16. require_once(TANGRA_MAIN_DIR.'form/fields/money/form_field_money.class.php');
  17.  
  18.  
  19. /**
  20.  * Represents text field that accepts positive money
  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.      * @param string $thousands_separator Thousands separator
  33.      * @param string $floating_separator Decimal separator
  34.      */
  35.     function __construct($name$required false$maxlength 100$value NULL$thousands_separator ' '$floating_separator '.'{
  36.         parent::__construct($name$required$maxlength$value$thousands_separator$floating_separator);
  37.  
  38.         $this->add_potential_error('money_expecting_positive');
  39.     }
  40.  
  41.  
  42.     /**
  43.      * Performs basic check for validity
  44.      *
  45.      * @return boolean 
  46.      * @internal
  47.      */
  48.     public function basic_check({
  49.         $has_errors parent::basic_check();
  50.  
  51.         if (!$has_errors{
  52.             if ($this->convert_money_to_int($this->get_html_value()) 0{
  53.                 $this->set_error('money_expecting_positive');
  54.                 $has_errors true;
  55.             }
  56.         }
  57.  
  58.         return $has_errors;
  59.     }
  60. }