Unknown form action in "beginWidget"

Hi all,

Simple and quick question. In a contact view (Yii sample project) I’ve got the following code that starts a form:

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






)); ?>

Looking at the source page I see the form action as follows:

... action="/addressBookYii/index.php?r=site/contact" ...

Could anyone please tell me where does that come from?

Thanks a lot.


This is automatically generated based on current controller/action. you can change it using htmlOptions of in the 1st array as


'action'=>'Value you want'


Thank you so much for the reply.

If it is auto-generated I suppose that the page will loop and self-reload (controller/action) when the submit button is pressed. In that sense, I assume the logic of the action in that controller has to detect somehow when the page is originally loaded or when it is loaded from the click on the submit button.

I just had a look at the controller and it implements an ‘if’ statement to check whether the ‘$_POST’ is set. And as you suggested, I’ve found that the action could be changed in the htmlOptions if needed.

Thanks again.