ybrunet
(Yakitabrunet)
December 1, 2011, 4:48pm
1
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
jacmoe
(Jacob Moena)
December 1, 2011, 5:23pm
2
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,
)
,));
ybrunet
(Yakitabrunet)
December 1, 2011, 6:52pm
3
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!
ybrunet
(Yakitabrunet)
December 1, 2011, 7:45pm
4
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…
jacmoe
(Jacob Moena)
December 1, 2011, 8:31pm
5
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,