《应用Yii1.1...敏捷Web开发》 actionAdduser的问题 [ 未指定版本 ]
我在添加 这个action到ProjectController类的时候 显示
Missing argument 1 for ProjectController::loadModel(), called in /home/wwwroot/trackstar/protected/controllers/ProjectController.php on line 197 and defined
public function actionAdduser()
{
<span class="php-hl-var" style="color: blue;">$form</span><span class="php-hl-code" style="color: gray;">=</span><span class="php-hl-reserved" style="font-weight: bold;">new</span> <span class="php-hl-identifier" style="color: green;">ProjectUserForm</span><span class="php-hl-code" style="color: gray;">;
</span><span class="php-hl-var" style="color: blue;">$project</span><span class="php-hl-code" style="color: gray;"> = </span><span class="php-hl-var" style="color: blue;">$this</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">loadModel</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-brackets" style="color: olive;">)</span><span class="php-hl-code" style="color: gray;">;</span><span class="php-hl-code"><span style="color:#ff0000;">// 这一段的loadModel() 上面的函数只有 loadModel($id),</span></span><span class="php-hl-code" style="color: gray;">
</span><span class="php-hl-comment" style="color: rgb(128, 128, 128); font-style: italic;">//</span><span class="php-hl-comment" style="color: rgb(128, 128, 128); font-style: italic;"> collect user input data</span>
<span class="php-hl-reserved" style="font-weight: bold;">if</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-reserved" style="font-weight: bold;">isset</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-var" style="color: blue;">$_POST</span><span class="php-hl-brackets" style="color: olive;">[</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-string" style="color: red;">ProjectUserForm</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-brackets" style="color: olive;">]</span><span class="php-hl-brackets" style="color: olive;">)</span><span class="php-hl-brackets" style="color: olive;">)</span> <span class="php-hl-brackets" style="color: olive;">{</span>
<span class="php-hl-var" style="color: blue;">$form</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">attributes</span><span class="php-hl-code" style="color: gray;">=</span><span class="php-hl-var" style="color: blue;">$_POST</span><span class="php-hl-brackets" style="color: olive;">[</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-string" style="color: red;">ProjectUserForm</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-brackets" style="color: olive;">]</span><span class="php-hl-code" style="color: gray;">;
</span><span class="php-hl-var" style="color: blue;">$form</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">project</span><span class="php-hl-code" style="color: gray;"> = </span><span class="php-hl-var" style="color: blue;">$project</span><span class="php-hl-code" style="color: gray;">; </span><span class="php-hl-comment" style="color: rgb(128, 128, 128); font-style: italic;">//</span><span class="php-hl-comment" style="color: rgb(128, 128, 128); font-style: italic;"> validate user input and set a sucessfull flassh message if valid</span>
<span class="php-hl-reserved" style="font-weight: bold;">if</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-var" style="color: blue;">$form</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">validate</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-brackets" style="color: olive;">)</span><span class="php-hl-brackets" style="color: olive;">)</span>
<span class="php-hl-brackets" style="color: olive;">{</span>
<span class="php-hl-identifier" style="color: green;">Yii</span><span class="php-hl-code" style="color: gray;">::</span><span class="php-hl-identifier" style="color: green;">app</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-brackets" style="color: olive;">)</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">user</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">setFlash</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-string" style="color: red;">success</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-code" style="color: gray;">,</span><span class="php-hl-var" style="color: blue;">$form</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">username</span><span class="php-hl-code" style="color: gray;"> . </span><span class="php-hl-quotes" style="color: red;">"</span><span class="php-hl-string" style="color: red;"> has been added to the project.</span><span class="php-hl-quotes" style="color: red;">"</span> <span class="php-hl-brackets" style="color: olive;">)</span><span class="php-hl-code" style="color: gray;">;
</span><span class="php-hl-var" style="color: blue;">$form</span><span class="php-hl-code" style="color: gray;">=</span><span class="php-hl-reserved" style="font-weight: bold;">new</span> <span class="php-hl-identifier" style="color: green;">ProjectUserForm</span><span class="php-hl-code" style="color: gray;">;
</span><span class="php-hl-brackets" style="color: olive;">}</span>
<span class="php-hl-brackets" style="color: olive;">}</span>
<span class="php-hl-comment" style="color: rgb(128, 128, 128); font-style: italic;">//</span><span class="php-hl-comment" style="color: rgb(128, 128, 128); font-style: italic;"> display the add user form </span>
<span class="php-hl-var" style="color: blue;">$users</span><span class="php-hl-code" style="color: gray;"> = </span><span class="php-hl-identifier" style="color: green;">User</span><span class="php-hl-code" style="color: gray;">::</span><span class="php-hl-identifier" style="color: green;">model</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-brackets" style="color: olive;">)</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">findAll</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-brackets" style="color: olive;">)</span><span class="php-hl-code" style="color: gray;">;
</span><span class="php-hl-var" style="color: blue;">$usernames</span><span class="php-hl-code" style="color: gray;">=</span><span class="php-hl-reserved" style="font-weight: bold;">array</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-brackets" style="color: olive;">)</span><span class="php-hl-code" style="color: gray;">;
</span><span class="php-hl-reserved" style="font-weight: bold;">foreach</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-var" style="color: blue;">$users</span> <span class="php-hl-reserved" style="font-weight: bold;">as</span> <span class="php-hl-var" style="color: blue;">$user</span><span class="php-hl-brackets" style="color: olive;">)</span>
<span class="php-hl-brackets" style="color: olive;">{</span>
<span class="php-hl-var" style="color: blue;">$usernames</span><span class="php-hl-brackets" style="color: olive;">[</span><span class="php-hl-brackets" style="color: olive;">]</span><span class="php-hl-code" style="color: gray;">=</span><span class="php-hl-var" style="color: blue;">$user</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">username</span><span class="php-hl-code" style="color: gray;">;
</span><span class="php-hl-brackets" style="color: olive;">}</span>
<span class="php-hl-var" style="color: blue;">$form</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">project</span><span class="php-hl-code" style="color: gray;"> = </span><span class="php-hl-var" style="color: blue;">$project</span><span class="php-hl-code" style="color: gray;">;
</span><span class="php-hl-var" style="color: blue;">$this</span><span class="php-hl-code" style="color: gray;">-></span><span class="php-hl-identifier" style="color: green;">render</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-string" style="color: red;">adduser</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-code" style="color: gray;">,</span><span class="php-hl-reserved" style="font-weight: bold;">array</span><span class="php-hl-brackets" style="color: olive;">(</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-string" style="color: red;">model</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-code" style="color: gray;">=></span><span class="php-hl-var" style="color: blue;">$form</span><span class="php-hl-code" style="color: gray;">, </span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-string" style="color: red;">usernames</span><span class="php-hl-quotes" style="color: red;">'</span><span class="php-hl-code" style="color: gray;">=></span><span class="php-hl-var" style="color: blue;">$usernames</span><span class="php-hl-brackets" style="color: olive;">)</span><span class="php-hl-brackets" style="color: olive;">)</span><span class="php-hl-code" style="color: gray;">;
}
函数就只有这个 public function loadModel($id)
{
$model=Project::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
求问应该怎么改
最佳答案
其他 0 个回答
没有找到数据。
MK.Elias
注册时间:2013-11-25
最后登录:2013-12-25
在线时长:3小时50分
最后登录:2013-12-25
在线时长:3小时50分
- 粉丝0
- 金钱0
- 威望0
- 积分30