Render doesn't go back to the url specified


I’ve a problem with rendering back to the url specified and I can’t seem to find any ways to solve it.

I’m new to yii framework and I’m not sure what I’m doing is correct.

Basically, what I’m trying to do is when I click on a link at a page, a pop-up form will appear so that I can fill in accordingly. When I click on the submit button on the form, it will go to the controller which will then communicate with the respective modal to save the info filled in by the user in the pop-up form to the database. Thereafter, the pop-up form will close and it will direct the user back to page with the link.

My directory structure:

[b]Project Module


 - index.php

 - ProjectDialog.php



    - DefaultController.php


 - Project.php

In index.php, it has a link and when clicked, it calls a cjuidialog which renders a form from ProjectDialog.php:


echo CHtml::link('Create Project', '#', array(

	'onclick'=>'$("#mydialog").dialog("open"); return true;',




$this->beginWidget('zii.widgets.jui.CJuiDialog', array(










echo $this->renderPartial('ProjectDialog', array('modelProject'=>$modelProject, 'list'=>$list));


ProjectDialog.php is a cactiveform:


$form=$this->beginWidget('CActiveForm', array(



	'enableClientValidation' => true,

	'clientOptions' => array('validateOnSubmit'=>true),

	'action'=>array('Default/SubmitProject'), //call DefaultController.php, actionSubmitProject method



DefaultController.php processes the cactiveform of ProjectDialog.php. It should render back to project module’s index.php view (view’s url only - index.php?r=project:

public function actionSubmitProject()


   ... //logic to communicate with modal

   $this->render('index', array('modelProject'=>$modelProject, 'list'=>$list,)); //should direct back to index.php?r=project but it keeps going to index.php?r=project/Default/SubmitProject


For the DefaultController.php, it should render back to project module’s index.php view (i.e. url should be view’s url only - index.php?r=project) but the url keeps displaying the view with controller action url(i.e. index.php?r=project/Default/SubmitProject).

The page displayed is the page that I want (index.php) but the url is not the correct url (it shows index.php?r=project/Default/SubmitProject instead of index.php?r=project).

I want the url to be view’s url only (index.php?r=project) because if it is at the view controller action url(index.php?r=project/Default/SubmitProject), and I refresh the page, it will keep running the into the controller action which creates multiple entries into the database.

Is there any way to solve the problem? Or is the method that I’m currently doing wrong?


Dear Friend,

I have one doubt. What is your directory structure.

You have given.:

Project Module


  • index.php

  • ProjectDialog.php



  • DefaultController.php


  • Project.php

I think it is:

Project Module



  • index.php

  • ProjectDialog.php


  • DefaultController.php


  • Project.php

Moreover viewfiles are not going to decide your url structure.(correct me if I am wrong).

It is constructed on ModuleId,ControllerId and ActionId.

In that aspect, I think what you are getting is correct.

If you are desperate in getting "index.php?r=project",I think you have to shift all the contents

of actionSubmitProject method into actionIndex method.

Regarding multiple database entries on page reloads, you can redirect the page to somewhere after successfully

saving the data.I hope it helps.