Hi,
i have this piece of code:
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('userid, email, amount, paywith', 'required'),
array('paywith, userid', 'numerical', 'integerOnly'=>true),
array('amount', 'numerical', 'integerOnly'=>false, 'min'=>self::$_Options['min'], 'max'=>self::$_Options['max']),
array('userid, amount', 'length', 'max'=>10),
array('email', 'length', 'min'=>5, 'max'=>255),
array('email', 'email'),
array('amount', 'usercheck', 'on'=>'user'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, userid, email, amount, paywith, date', 'safe', 'on'=>'search'),
);
}
public function usercheck($attribute,$params)
{
$this->userid = Yii::app()->user->getId(); // No hacking
$email = NULL;
$isvalidemail = Payment::userHavePaymentEmail($this->paywith, $email);
if(!$isvalidemail)
$this->addError('paywith', 'You don\'t have an email account for the requested payment.');
else
$this->email = $email;
var_dump($this->email);
$money = User::myGetMoney();
if($this->amount > $money)
{
$this->addError('amount', 'You don\'t have <strong>'.$this->amount.'€</strong> in your account.');
}
}
in my var_dump after email got checked it shows a valid email, the problem is after that values dont keep on variables. maybe yii protection?
and im getting this error:
Note that id and email is never seted on form POST/VIEW
Thanks