Validate Dont Show Errors


public function actionCreate() {


        $model = new Preco();

        $this->actionValida();

        $cod_casa = Yii::app()->getRequest()->getQuery('cod_casa');


        $this->actionCalendar($cod_casa, 0);

        // $this->performAjaxValidation($model);


        if (isset($_POST['Preco'])) {


            $model->attributes = $_POST['Preco'];

            $model->validate();

            $model->save();

        }


        $this->redirect(array('casa/view', 'id' => $cod_casa, 'fromP' => '1',));

    }

Because you gave it no chance to show errors :)

$model->validate() - returns false, no error output,

$model->save() - returns false, no error output,

$this->redirect() - redirects to some page, no error output.

Instead, do this:




if (isset($_POST['Preco'])) {

	$model->attributes = $_POST['Preco'];

	if ($model->save()) {

                 // optionally set success flash message

		$this->redirect(array('casa/view', 'id' => $cod_casa, 'fromP' => '1',));

	} else {

            // optionally set error flash message

        }

}


$this->render('create');



thanks