http://yii/trackstar/index.php?r=project/view&id=2
I'm getting an error, as described at the screen shot at the bottom. but I did followed the instructions
the exact code snippets to move on., what should I do to fix this and move forward ?
Posted 06 November 2010 - 12:30 PM
http://yii/trackstar/index.php?r=project/view&id=2
Posted 06 November 2010 - 12:38 PM
$model = $this->loadModel();
$model = $this->loadModel($_GET['id']);
Posted 06 November 2010 - 12:51 PM
Y!!, on 06 November 2010 - 12:38 PM, said:
$model = $this->loadModel();
$model = $this->loadModel($_GET['id']);
<?php
class ProjectController extends Controller
{
/**
* @var string the default layout for the views. Defaults to '//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='//layouts/column2';
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
// $this->render('view',array(
// 'model'=>$this->loadModel($id),
// ));
$issueDataProvider = new CActiveDataProvider('Issue', array(
'criteria' => array(
'condition' => 'project_id=:projectId',
'params'=> array(':projectId'=>$this->loadModel()->id),
),
'pagination'=>array(
'pageSize' => 1,
),
));
$this->render('view', array(
'model' => $this->loadModel(),
'issueDataProvider' => $issueDataProvider,
));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model=new Project;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Project']))
{
$model->attributes=$_POST['Project'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Project']))
{
$model->attributes=$_POST['Project'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
else
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Project');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Project('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Project']))
$model->attributes=$_GET['Project'];
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model=Project::model()->findByPk((int)$id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param CModel the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='project-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
Posted 06 November 2010 - 12:54 PM
$this->render('view', array(
'model' => $this->loadModel($id),
'issueDataProvider' => $issueDataProvider,
));
Posted 06 November 2010 - 01:05 PM
Y!!, on 06 November 2010 - 12:54 PM, said:
$this->render('view', array(
'model' => $this->loadModel($id),
'issueDataProvider' => $issueDataProvider,
));
'params'=> array(':projectId'=>$this->loadModel()->id),

Posted 06 November 2010 - 01:08 PM
public function actionView($id)
{
// $this->render('view',array(
// 'model'=>$this->loadModel($id),
// ));
$issueDataProvider = new CActiveDataProvider('Issue', array(
'criteria' => array(
'condition' => 'project_id=:projectId',
'params'=> array(':projectId'=>$this->loadModel($id)->id),
),
'pagination'=>array(
'pageSize' => 1,
),
));
$this->render('view', array(
'model' => $this->loadModel($id),
'issueDataProvider' => $issueDataProvider,
));
}
Posted 06 November 2010 - 03:06 PM
Posted 10 March 2011 - 06:42 AM
'params'=>array(':projectId'=>$this->loadModel($id)->id),
Posted 15 April 2011 - 07:48 AM
Posted 18 April 2011 - 11:38 AM
Posted 29 May 2011 - 12:46 AM
public function actionView($id)
{
$issueDataProvider=new CActiveDataProvider('Issue', array(
'criteria'=>array(
'condition'=>'project_id=:projectId',
'params'=>array(':projectId'=>$this->loadModel($id)->id),
),
'pagination'=>array(
'pageSize'=>1,
),
));
$this->render('view',array(
'model'=>$this->loadModel($id),
'issueDataProvider'=>$issueDataProvider,
));
]CException
Issue does not have a method named "getTypeText".
/Applications/MAMP/htdocs/framework/base/CComponent.php(266)
254 public function __call($name,$parameters)
255 {
256 if($this->_m!==null)
257 {
258 foreach($this->_m as $object)
259 {
260 if($object->getEnabled() && method_exists($object,$name))
261 return call_user_func_array(array($object,$name),$parameters);
262 }
263 }
264 if(class_exists('Closure', false) && $this->canGetProperty($name) && $this->$name instanceof Closure)
265 return call_user_func_array($this->$name, $parameters);
266 throw new CException(Yii::t('yii','{class} does not have a method named "{name}".',
267 array('{class}'=>get_class($this), '{name}'=>$name)));
268 }
269
270 /**
271 * Returns the named behavior object.
272 * The name 'asa' stands for 'as a'.
273 * @param string $behavior the behavior name
274 * @return IBehavior the behavior object, or null if the behavior does not exist
275 * @since 1.0.2
276 */
277 public function asa($behavior)
278 {[/b]
}
Posted 29 May 2011 - 01:29 AM
Posted 13 October 2011 - 01:07 PM
'params'=>array(':projectId'=>$this->loadModel($id)->id),'params'=>array(':projectId'=>$id,
Posted 17 December 2011 - 05:22 AM
Posted 25 March 2013 - 10:36 PM
pietrop, on 10 March 2011 - 06:42 AM, said:
'params'=>array(':projectId'=>$this->loadModel($id)->id),