I am trying to add a new action to my controller for the first time. The action is supposed to be called "record" and should take any string.
This is what I added to my EventController:
/**
* Record an event triggered by API
* @param string $data the data provided by the API
*/
public function actionRecord($data){
$this->render('record',array('data'=>$data));
}
I also modified the default access control so that all have access:
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view','record'),
'users'=>array('*'),
),
My view called record.php is pretty simple:
<pre>
<?php
print_r($data);
?>
</pre>
Yet when I go to the URL /index.php/event/record/12 , I get a 400 error, and the logs say:
2011/08/22 16:57:17 [error] [exception.CHttpException.400] exception 'CHttpException' with message 'Your request is invalid.' in /Users/nathan/Git/MyProject/web/yii/web/CController.php:328
Stack trace:
#0 /Users/nathan/Git/MyProject/web/yii/web/CController.php(301): CController->invalidActionParams(Object(CInlineAction))
#1 /Users/nathan/Git/MyProject/web/yii/web/filters/CFilterChain.php(134): CController->runAction(Object(CInlineAction))
#2 /Users/nathan/Git/MyProject/web/yii/web/filters/CFilter.php(41): CFilterChain->run()
#3 /Users/nathan/Git/MyProject/web/yii/web/CController.php(1144): CFilter->filter(Object(CFilterChain))
#4 /Users/nathan/Git/MyProject/web/yii/web/filters/CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
#5 /Users/nathan/Git/MyProject/web/yii/web/filters/CFilterChain.php(131): CInlineFilter->filter(Object(CFilterChain))
#6 /Users/nathan/Git/MyProject/web/yii/web/CController.php(283): CFilterChain->run()
#7 /Users/nathan/Git/MyProject/web/yii/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#8 /Users/nathan/Git/MyProject/web/yii/web/CWebApplication.php(277): CController->run('record')
#9 /Users/nathan/Git/MyProject/web/yii/web/CWebApplication.php(136): CWebApplication->runController('event/record')
#10 /Users/nathan/Git/MyProject/web/yii/base/CApplication.php(158): CWebApplication->processRequest()
#11 /Users/nathan/Git/MyProject/web/http/index.php(13): CApplication->run()
#12 {main} REQUEST_URI=/index.php/event/record/12
What am I missing?