Note that there are some explanatory texts on larger screens.

plurals
  1. POProperly implementing runWithParams() in Yii
    primarykey
    data
    text
    <p>If you look under #3 in this link <a href="http://www.yiiframework.com/doc/guide/1.1/en/basics.controller" rel="nofollow">http://www.yiiframework.com/doc/guide/1.1/en/basics.controller</a> it gives you a way to organize all of your controller functions into individual php files.</p> <p>To do this you have to have each php file contain a class that extends CAction. Each class must have its running code inside of the function run(). </p> <p>This is my UserController.php file</p> <pre><code>public function actions() { $FOLDER = '.User'; $PROJECT_ROOT = 'application.controllers' . $FOLDER; return array ( 'list' =&gt; $PROJECT_ROOT . 'ListAction', ); </code></pre> <p>}</p> <p>In the application that I am writing I need to pass variables to specific Actions.</p> <p>Yii implemented runWithParams($params) in Yii 1.7 to allow this to happen. However, when I call write in the (for example) DeleteAction.php file runWithParams($params) instead of run() and our front end calls post/delete/?params=45 instead of run() I get an error that says "could not find run() in file DeleteAction.php</p> <pre><code>class ListAction extends CAction { public function runWithParam($id) { SiteController::actionLoggedin(); $id = addslashes($id); } </code></pre> <p>Which means that I need run()...but I can't pass parameters into run(). I need runWithParams($params).</p> <p>In the documentation for the function runWithParams($params) <a href="http://www.yiiframework.com/doc/api/1.1/CAction#runWithParams-detail" rel="nofollow">http://www.yiiframework.com/doc/api/1.1/CAction#runWithParams-detail</a></p> <p>it says</p> <pre><code> Runs the action with the supplied request parameters. This method is internally called by CController::runAction(). </code></pre> <p>I am confused what this means? I don't understand how I can implement this successfully.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload