I am getting again the warning:
Missing argument 1 for ProjectController::loadModel()
The solution from previous ticket does not work:
What can be done?
Full warning description:
PHP warning
Missing argument 1 for ProjectController::loadModel(), called in C:\xampp\htdocs\demo2\protected\controllers\ProjectController.php on line 64 and defined
C:\xampp\htdocs\demo2\protected\controllers\ProjectController.php(178)
166 $this->render('admin',array(
167 'model'=>$model,
168 ));
169 }
170
171 /**
172 * Returns the data model based on the primary key given in the GET variable.
173 * If the data model is not found, an HTTP exception will be raised.
174 * @param integer $id the ID of the model to be loaded
175 * @return Project the loaded model
176 * @throws CHttpException
177 */
178 public function loadModel($id)
179 {
180 $model=Project::model()->findByPk($id);
181 if($model===null)
182 throw new CHttpException(404,'The requested page does not exist.');
183 return $model;
184 }
185
186 /**
187 * Performs the AJAX validation.
188 * @param Project $model the model to be validated
189 */
190 protected function performAjaxValidation($model)
Stack Trace
#0
–
C:\xampp\htdocs\demo2\protected\controllers\ProjectController.php(64): ProjectController->loadModel()
59 {
60 //$id=$this->loadModel()->id;
61 $issueDataProvider=new CActiveDataProvider('Issue', array(
62 'criteria'=>array(
63 'condition'=>'project_id=:projectId',
64 'params'=>array(':projectId'=>$this->loadModel()->id),
65 // 'params'=>array(':projectId'=>$id),
66 ),
67 'pagination'=>array(
68 'pageSize'=>1,
69 ),
#1
+
C:\xampp\htdocs\yii\framework\web\actions\CInlineAction.php(49): ProjectController->actionView()
#2
+
C:\xampp\htdocs\yii\framework\web\CController.php(308): CInlineAction->runWithParams(array("r" => "project/view", "id" => "2"))
#3
+
C:\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(133): CController->runAction(CInlineAction)
#4
+
C:\xampp\htdocs\yii\framework\web\filters\CFilter.php(40): CFilterChain->run()
#5
+
C:\xampp\htdocs\yii\framework\web\CController.php(1145): CFilter->filter(CFilterChain)
#6
+
C:\xampp\htdocs\yii\framework\web\filters\CInlineFilter.php(58): CController->filterAccessControl(CFilterChain)
#7
+
C:\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(CFilterChain)
#8
+
C:\xampp\htdocs\yii\framework\web\CController.php(291): CFilterChain->run()
#9
+
C:\xampp\htdocs\yii\framework\web\CController.php(265): CController->runActionWithFilters(CInlineAction, array("accessControl", "postOnly + delete"))
#10
+
C:\xampp\htdocs\yii\framework\web\CWebApplication.php(282): CController->run("view")
#11
+
C:\xampp\htdocs\yii\framework\web\CWebApplication.php(141): CWebApplication->runController("project/view")
#12
+
C:\xampp\htdocs\yii\framework\base\CApplication.php(180): CWebApplication->processRequest()
#13
–
C:\xampp\htdocs\demo2\index.php(13): CApplication->run()
08 defined('YII_DEBUG') or define('YII_DEBUG',true);
09 // specify how many levels of call stack should be shown in each log message
10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
11
12 require_once($yii);
13 Yii::createWebApplication($config)->run();
If i try solution from the previous ticket does not work:
If i change ‘params’
// 'params'=>array(':projectId'=>$this->loadModel()->id),
'params'=>array(':projectId'=>$id),
and render:
$this->render('view',array(
// 'model'=>$this->loadModel(),
'model'=>$this->loadModel($id),
'issueDataProvider'=>$issueDataProvider,
I am getting notice:
Undefined variable: id
If i try to define id as
$id=$this->loadModel()->id;
public function actionView()
{
$id=$this->loadModel()->id;
$issueDataProvider=new CActiveDataProvider('Issue', array(
'criteria'=>array(
'condition'=>'project_id=:projectId',
// 'params'=>array(':projectId'=>$this->loadModel()->id),
'params'=>array(':projectId'=>$id),
),
'pagination'=>array(
'pageSize'=>1,
),
));
$this->render('view',array(
// 'model'=>$this->loadModel(),
'model'=>$this->loadModel($id),
'issueDataProvider'=>$issueDataProvider,
));
i am getting again warning, that : Missing argument 1 for ProjectController::loadModel(), called in C:\xampp\htdocs\demo2\protected\controllers\ProjectController.php on line 60