Partial Render.

I have a player controller. And in my player’s index view i used renderPartial() to display create view.

The index view is:

<div id="t_list">


<?php $this->widget('zii.widgets.CListView', array(



)); ?>


<div id="t_Addform">


        $model= new Player;

        $this->renderPartial('/player/create', array('model'=>$model));



when player is created and there is validation error, it jumps to player/create view.To fix this i did following.














It works okay, But if there is validation error, error message aren’t displayed in the index view. How do i show error message in the index view too?

Is there anyreason you are doing a redirect rather than re rendering the page. The models errors gets populated only after a save or a validate call fails so by redirecting the page rather than rendering it the model validation information is not being passed trough so ether you need redo the validation on the other screen or you need to change the code as follows to render the error on the create page

In your form set your action to //player/index

then on your actionIndex controller action do this:

public function actionIndex() {

    $dataProvider= {how you get the dataprovider};

    $model = new Player;

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

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

        if ($model->save()) {




    $this->render('index',array('dataProvider'=>$dataProvider, 'model'=>$model))


This should fix your validation issue and be allot less of a code hasel as you could remove the actionCreate completely

Thank you a lot. It is what i want to do.