Hello Yii,
I am working in my localhost environment:
XAMPP
PHP version 5.3.8
PHPmyadmin (MySQL) version 5.0.8
My webroot directory is:
C:\XAMPP\htdocs\
And my base directory for the MyProject site is:
C:\XAMPP\htdocs\YII\MyProject
In page#118:
public function actionCreate()
{
$model=new Issue;
$model->project_id = $this->_project->id;
and i got error message. it says:
PHP notice
Trying to get property of non-object
C:\XAMPP\htdocs\YII\MyProject\protected\controllers\IssueController.php(67)
55 $this->render(‘view’,array(
56 ‘model’=>$this->loadModel($id),
57 ));
58 }
59
60 /**
61 * Creates a new model.
62 * If creation is successful, the browser will be redirected to the ‘view’ page.
63 */
64 public function actionCreate()
65 {
66 $model=new Issue;
67 $model->project_id= $this->_project->id;
68
69 // Uncomment the following line if AJAX validation is needed
70 // $this->performAjaxValidation($model);
71
72 if(isset($_POST[‘Issue’]))
73 {
74 $model->attributes=$_POST[‘Issue’];
75 if($model->save())
76 $this->redirect(array(‘view’,‘id’=>$model->id));
77 }
78
79 $this->render(‘create’,array(
Stack Trace
#0
C:\XAMPP\htdocs\YII\framework\web\actions\CInlineAction.php(50): IssueController->actionCreate()
#1
…
…
In issueController.php
…
…
public function actionCreate()
{
$model=new Issue;
$model->project_id= $this->_project->id;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Issue']))
{
$model->attributes=$_POST['Issue'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
));
}
…
…
Does anyone have any ideas or suggestions and how to solve the problem?
Thanks
Best Wishes,
Adnan
menezes
(Menezes Web)
March 15, 2012, 1:00am
2
In my controller this actcion is as follow
public function actionAdmin()
{
$model=new Issue('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Issue']))
$model->attributes=$_GET['Issue'];
$model->project_id = $this->_project->id;
$this->render('admin',array(
'model'=>$model,
));
}
Try it.
it is working well but the book did not say that!!! i want create function…not admin function.
menezes
(Menezes Web)
March 15, 2012, 5:36pm
4
I think that code that I copy you is default. I remember, I only change small things.