im rying to display a flash message after a user gat an error
this is my controller
public function actionCreate()
{
$this->layout = 'calendar2';
$model=new Calendrier;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Calendrier']))
{
$model->attributes=$_POST['Calendrier'];
if($model->test==0){
$id=$model->nom_ancien;
$recordPatient= Patient::model()->findByPk($id);
$model->nom_prenom_du_patient = $recordPatient->nom.' '. $recordPatient->prenom ;
}else{
$model->nom_prenom_du_patient = $model->nom_nouveau;
}
if ($model->temp_debut < $model->temp_fin)
{
$date1 = strtotime($model->temp_debut);
$date2 = strtotime($model->temp_fin);
$subTime = $date2 - $date1;
$m = ($subTime/60);
if ($m <= 60)
{
$date_debut = DateTime::CreateFromFormat("Y-m-d H:i:s", $model->temp_debut);
$heures = $date_debut ->format('H:i:s'); // '07'
$date_fin = DateTime::CreateFromFormat("Y-m-d H:i:s", $model->temp_fin);
$heures1 = $date_fin ->format('H:i:s'); // '07'
if( ($heures >= '06:00:00') && ($heures1 <= '20:00:00') )
{
if($model->save()){
$this->redirect(array('view','id'=>$model->id));
}
}
else
{
Yii::app()->user->setFlash('erreur','Le temp de debut du rendez vous doit etre Supérieur au temp de fin ');
$this->refresh();
}
}
else
{
Yii::app()->user->setFlash('erreur','Le rendez vous ne doit pas depasser les 60 minutes');
$this->refresh();
}
}
else
{
Yii::app()->user->setFlash('erreur','Les rendez vous commencent a 6h est finissenet à 20h');
$this->refresh();
}
}
$this->render('create',array(
'model'=>$model,
));
}
thisis my view
<?php if(Yii::app()->user->hasFlash('erreur')){?>
<div class="info">
<?php echo Yii::app()->user->getFlash('erreur'); ?>
</div>
<?php} else{ ?>
<h1>Nouveau Certificat</h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
<?php }?