/** * (non-PHPdoc) * @see lib/form/validator/phValidator::validate() */ public function validate($value, phValidatable $errors) { $compareValue = $this->_compareWith instanceof phData ? $this->_compareWith->getValue() : $this->_compareWith; $valid = false; switch ($this->_operator) { case self::EQUAL: $valid = $value == $compareValue; break; case self::NOT_EQUAL: $valid = $value != $compareValue; break; case self::GREATER_THAN: $valid = $value > $compareValue; break; case self::GREATER_EQUAL: $valid = $value >= $compareValue; break; case self::LESS_THAN: $valid = $value < $compareValue; break; case self::LESS_EQUAL: $valid = $value <= $compareValue; break; } if (!$valid) { $errors->addError($this->getError(self::INVALID)); } return $valid; }
/** * (non-PHPdoc) * @see lib/form/phDataChangeListener::dataChanged() */ public function dataChanged(phFormDataItem $item) { if ($item instanceof phSimpleArrayDataItem) { /* * $item->getValue will be an array, we need to see if our * value is in it - if so set ourselves to checked by calling * $this->setValue */ $values = $item->getValue(); $ourValue = $this->getRawValue(); if (in_array($ourValue, $values)) { $this->checkOn(); } else { $this->checkOff(); } } else { parent::dataChanged($item); } }
/** * When a phform element in the view is found a phFormDataItem instance is created * and then when, in bind it has its values set * @see lib/form/phDataChangeListener::dataChanged() */ public function dataChanged(phFormDataItem $item) { $this->setValue($item->getValue()); }