[Solved] Forcing contact form to display iself after message is sent

Hi there,

This is indeed a silly or even dumb question, but I must be missing something, because I tried as I think everything and got no result.

When one uses original contact form generated by yiic webapp a message confirming e-mail delivery displays on separate screen. How to force it to be displayed on top of new (empty) contact form? Just like error messages are being displayed.

Displaying whole page with only one line of info text does not satisfy me. Beside, I want to include in confirm message an information, that user can use BELOW form again to send another message.

This is a flash message therefore I was more than sure that it WILL display itself on top of a contact form. Apparently it is not. Tried with original $this->refresh() and my own $this->render(‘contact’, array(‘model’=>$model)) or $this->redirect(Yii::app()->createUrl(‘main/contact’)). Each time no effect.

Any advice? Thanks in advance!

The controller is fine… it renders the view contact.php…

In the original contact.php there is this code




<?php 


if(Yii::app()->user->hasFlash('contact')): ?> 


   <div class="flash-success">

      <?php echo Yii::app()->user->getFlash('contact'); ?>

   </div> 


<?php else: ?>

   ...

   // contact form

   ...

<?php endif; ?>



So you can just remove the IF ELSE statements… and the message will be displayed together with the contact form…

Thanks! I’ve decided to change <?php else: ?> with <?php endif; ?>. This way, if there is not flash, there is no additional div being rendered.

Problem solved. Continue on this forum post for a very similar, e-mail sending-related problem with Yii.