Код: Выделить всё
$expire_date_error = '
Please enter the company license expire date more than notification days
[list]
[*]Expire Date is less than notificaion days on current date.
[/list]';
Yii::app()->user->setFlash('expire_date_error',$expire_date_error);
$this->render('create',array(
'model'=>$model,
< /code>
Это получает MSG из View. < /p>
Согласно
=======================+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +=============================================================================================================================================================== мой контроллер < /p>
public function actionCreate()
{
$model=new CompanyLicense;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['CompanyLicense']))
{
$currentTime = date('Y-m-d h:i:s', time());
$model->attributes= $_POST['CompanyLicense'];
$model->created = $currentTime;
$model->active = 1;
$model->expire_date= $_POST['CompanyLicense']['expire_date'];
if($model->checkExpireDate())
{
$model->file_name=CUploadedFile::getInstance($model,'file_name');
$folder = Yii::getPathOfAlias('webroot').'/images/';
if($model->save())
{
mkdir($folder.$model->id);
$model->file_name->saveAs($folder. $model->id . "/" . $model->file_name);
$this->redirect(array('view','id'=>$model->id));
}
}else{
//echo 'debug';
$expire_date_error = '
Please enter the company license expire date more than notification days
- Expire Date is less than notificaion days on current date.
Yii::app()->user->setFlash('expire_date_error',$expire_date_error);
}
}
$this->render('create',array(
'model'=>$model,
));
}
public function checkExpireDate($attribute='',$params ='')
{
$currentTime = date('Y-m-d', time());
$currentTime = date('Y-m-d', strtotime($currentTime . '+ ' . $this->notification_days.' days'));
if ($currentTime > $this->expire_date)
return false;
return true;
//$this->addError($this->expire_date,'should be more ' . $this->notification_days . ' days on current date!');
}
< /code>
Я хочу показать эту ошибку с помощью другой проверки неудачная ошибка MSG. < /p>
Подробнее здесь: https://stackoverflow.com/questions/117 ... failed-msg