Form without DB

Hello all. I’m sorry if this has been asked before but how do I actually get a workaround to post/process something with a form’s input without using a database. I’m relatively new to this PHP Framework world so I’m sorry if I was supposed to see it somewhere but I didn’t.

e.g: Form requests for user for an input of number. Then the number is passed to a calculator class and displays the result?

Thanks in advance :)

The form with DB are inherited the CActiveRecord class, but only for form creation and checking the results you may use CFormModel class. Open the ContactForm.php model in blog example and you will see how it works

Alright. Thanks a lot. I guess I missed the ‘setFlash’ part. I was just curious since I’ll be performing the actions based from a different class and wasn’t quite sure how to pass it back to the form as a result (below it, etc). I guess I’ll look at ‘setFlash’ for now. Thanks again :)

It’s quite simple. In your controller you should write:

Yii::app()->user->setFlash('flashname','Data was saved successfully');

And in your view:

<?php if(Yii::app()->user->hasFlash('flashname')): ?>

	<div class="flash-success">

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


<?php endif; ?>

Yup. That’s pretty much how I’m doing it now. Here’s my current test code.


class Calculator {

    public static function Add($number1, $number2)


        return $number1+$number2;




<?php if(Yii::app()->user->hasFlash('calculator')): ?>


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


<?php endif; ?>



    Yii::app()->user->setFlash('calculator', Calculator::Add($this->number1, $this->number2));


Again, thanks a lot for point this out :)