How can I change "action" attribute of the form?

Hi,

I created a feedback form using CActiveForm:

$form=$this->beginWidget(‘CActiveForm’, array(

                 'id'=>'feedbackform',


		 'enableClientValidation'=>true,


		 'clientOptions'=>array(


	 	 'validateOnSubmit'=>true,


		),


	)); 

When I submit a form I’m getting the error below. It is because the form has the action=“feedback”, in which Yii thinks it is a controller and tries to load it and fail. How can I change the action of the form so that I can specify the “controller/action” to send the submit to?

exception ‘CHttpException’ with message 'Unable to resolve the request

“feedback”.’ in

/var/www/yii-1.1.8.r3324/framework/web/CWebApplication.php:281

Stack trace:

#0 /var/www/yii-1.1.8.r3324/framework/web/CWebApplication.php(136):

CWebApplication->runController(‘feedback’)

#1 /var/www/yii-1.1.8.r3324/framework/base/CApplication.php(158):

CWebApplication->processRequest()

#2 /var/www/morefun_sandbox/index.php(29): CApplication->run()

#3 {main} REQUEST_URI=/feedback

CActiveForm has an ‘action’ parameter. :)

Not a lot of information you provide, but you could try that.




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

array('id'=>'feedbackform',

'action' => array('<your_action>'),

'enableClientValidation'=>true,

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

)

,)); 

Thank you Jacmoe.

I didn’t know I can use ‘action’ parm. Great idea.

I just tried it by adding my <controller/action> to ‘action’ parameter.

‘action’ => array(‘site/feedback’),

But the resulting page with the form rendered had the different URL:

action = "index.php/feedback"

Do you happen to know how ‘action’ parameter is post-processed by Yii to generate url?

I’m puzzled!

OK. This route translation of ‘site/feedback’ to ‘index.php/feedback’ is due to urlManager.

I have a entry in main.php which match the pattern ‘feedback’.

So I need to find out exactly how urlManager is translating it…


        'urlManager' => array(

            'urlFormat' => 'path',

            'showScriptName' => false,