yii\base\Model::beforeValidate PHP Method

beforeValidate() public method

The default implementation raises a beforeValidate event. You may override this method to do preliminary checks before validation. Make sure the parent implementation is invoked so that the event can be raised.
public beforeValidate ( ) : boolean
return boolean whether the validation should be executed. Defaults to true. If false is returned, the validation will stop and the model is considered invalid.
    public function beforeValidate()
    {
        $event = new ModelEvent();
        $this->trigger(self::EVENT_BEFORE_VALIDATE, $event);
        return $event->isValid;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Method description
  *
  * @return mixed The return value
  */
 public function beforeValidate()
 {
     if (!empty($this->otherType)) {
         $this->type = $this->otherType;
     }
     return parent::beforeValidate();
 }
All Usage Examples Of yii\base\Model::beforeValidate