DBFieldEnum Class Reference
[Model]
An enum field. More...
Inheritance diagram for DBFieldEnum:
Public Member Functions |
|
__construct ($name, $allowed=array(), $default_value=null, $policy=self::NONE) | |
validate ($value) | |
Returns true, if the value passed fits the
fields restrictions. |
|
Protected Attributes |
|
$allowed |
Detailed Description
An enum field.
Definition at line 8 of file dbfield.enum.cls.php.
Constructor & Destructor Documentation
DBFieldEnum::__construct | ( | $ | name, | |
$ | allowed = array() , |
|||
$ | default_value =
null , |
|||
$ | policy =
self::NONE |
|||
) |
Reimplemented from DBField.
Definition at line 16 of file dbfield.enum.cls.php.
00016 { 00017 parent::__construct($name, $default_value, $policy); 00018 $this->allowed = Arr::force($allowed); 00019 }
Member Function Documentation
DBFieldEnum::validate | ( | $ | value | ) |
Returns true, if the value passed fits the fields restrictions.
- Parameters:
-
string $value
- Returns:
- Status
Reimplemented from DBField.
Reimplemented in DBFieldSet.
Definition at line 27 of file dbfield.enum.cls.php.
00027 { 00028 $ret = parent::validate($value); 00029 if ($ret->is_ok() && !is_null($value)) { 00030 if (!in_array($value, $this->allowed)) { 00031 $ret->append(tr( 00032 'Value %val not allowed on %field', 00033 'core', 00034 array( 00035 '%field' => $this->get_field_name_translation(), 00036 '%val' => $value 00037 ) 00038 )); 00039 } 00040 } 00041 return $ret; 00042 }
Member Data Documentation
DBFieldEnum::$allowed
[protected] |
Definition at line 14 of file dbfield.enum.cls.php.
The documentation for this class was generated from the following file:
- gyro/core/model/base/fields/dbfield.enum.cls.php