Hi,
im having a problem with $model->addError method,
in the view error not show
NOTE that both conditions are lead to addError
public function actionWithdraw()
{
require_once(dirname(__FILE__).'/../components/paypal/CPayPal.php');
$model = new PendingWithdraw;
$model->userid = Yii::app()->user->id;
if(isset($_POST['PendingWithdraw']))
{
$model->attributes=$_POST['PendingWithdraw'];
$model->addError('amount', 'You don\'t have <strong>'.$model->amount.'€</strong> in your account.');
$email = NULL;
$isvalidemail = Payment::userHavePaymentEmail($model->paywith, $email);
if(!$isvalidemail)
$model->addError('paywith', 'You dont have an email account for the requested payment.');
else
$model->email = $email;
$money = User::myGetMoney();
if($model->amount > $money)
{
$model->addError('amount', 'You don\'t have <strong>'.$model->amount.'€</strong> in your account.');
}
if($model->validate())
{
die('ok');
}
}
$data = array('model'=>$model);
$this->render('withdraw', $data);
}
my view:
<?php
$this->pageCaption='Withdraw';
$this->pageTitle=Yii::app()->name.' - '.$this->pageCaption;
$this->pageDescription='cashout funds';
?>
<div class="form">
<?php $form=$this->beginWidget('BActiveForm', array(
'id'=>'pending-withdraw-form',
'enableAjaxValidation'=>false,
)); ?>
<?php $this->widget('BAlert',array(
'content'=>'<p>Fields with <span class="required">*</span> are required.</p><p>You must have an email to the requested payment</p>'
)); ?>
<?php echo $form->errorSummary($model); ?>
<div class="<?php echo $form->fieldClass($model, 'amount'); ?>">
<?php echo $form->labelEx($model,'amount'); ?>
<div class="input">
<div class="input-append">
<?php echo $form->textField($model,'amount', array('maxlength'=>6,
'class'=>'span2 validate[required,custom[number],min['.PendingWithdraw::$_Options['min'].'],max['.PendingWithdraw::$_Options['max'].']]')); ?>
<span class="add-on"><strong>€</strong></span>
<?php echo $form->error($model,'amount'); ?>
</div>
</div>
</div>
<div class="<?php echo $form->fieldClass($model, 'paywith'); ?>">
<?php echo $form->labelEx($model,'paywith'); ?>
<div class="input">
<?php echo $form->dropDownList($model,'paywith', Payment::generateUserWithdrawPayWith(), array('class'=>'span8')); ?>
<?php echo $form->error($model,'paywith'); ?>
</div>
</div>
<div class="actions">
<?php echo BHtml::submitButton('Submit'); ?>
</div>
<?php $this->endWidget(); ?>
</div>
<?php Yii::app()->clientScript->registerScript('pending-withdraw-form-validator','$("#pending-withdraw-form").validationEngine();'); ?>
this model is a CActiveRecord
Thanks