Form_Field_ValueList::validateValidItem PHP Method

validateValidItem() public method

Validate POSTed field value.
public validateValidItem ( ) : boolean
return boolean
    public function validateValidItem()
    {
        if (!$this->value) {
            return;
        }
        // load allowed values in values_list
        // @todo Imants: Actually we don't need to load all values from Model in
        //       array, just to check couple of posted values.
        //       Probably we should do SELECT * FROM t WHERE id IN ($values) or
        //       something like that to limit array size and time spent on
        //       parsing all DB records in Model.
        $this->getValueList();
        $values = explode($this->separator, $this->value);
        foreach ($values as $v) {
            if (!isset($this->value_list[$v])) {
                $this->displayFieldError("Value {$v} is not one of the offered values");
                return $this->validate();
            }
        }
    }

Usage Example

Esempio n. 1
0
 function validateValidItem()
 {
     if ($this->validate_values) {
         return parent::validateValidItem();
     }
     return true;
 }