<?php

/**
 * 
 */
class FormularioEntradaRecuperarPassword extends CFormModel {

    public $email;

    public function rules() {
        return array(
        array('email', 'required'),
        array('email', 'email'),
        array('email', 'existeEmailUsuario'),
        );
    }

    public function existeEmailUsuario($attribute, $params) {
        if (!$this->hasErrors()) {
            $usuario = Usuario::model()->findByAttributes(array('email' => $this->email));

            if ($usuario === null)
                $this->addError($attribute, Yii::t('profind', 'Email incorrecto'));
        }
    }
}