Ares
(Draguna Ares)
July 14, 2014, 8:36am
1
Hi!
So… I have the following issue… In my actionIndex() in controller I have the following code:
public function actionIndex()
{
$model = $this->loadModel(Yii::app()->user->id);
if(isset($_POST['Resellerdetails']))
{
$model->attributes=$_POST['Resellerdetails'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$dataProvider=new CActiveDataProvider('Resellerdetails');
$this->render('index',array(
'dataProvider'=>$dataProvider,
[b]'model' => $model,[/b]
));
}
I have bolded that line for a reason… Moving on to index.php in the view, I have the following:
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
and then I get an:
Undefined variable: model
right before $form->errorSummary($model);
and I var_dumped the $model var right before that and the var exists… Any toughts?
Ares
(Draguna Ares)
July 14, 2014, 8:54am
2
Ares:
Hi!
So… I have the following issue… In my actionIndex() in controller I have the following code:
public function actionIndex()
{
$model = $this->loadModel(Yii::app()->user->id);
if(isset($_POST['Resellerdetails']))
{
$model->attributes=$_POST['Resellerdetails'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$dataProvider=new CActiveDataProvider('Resellerdetails');
$this->render('index',array(
'dataProvider'=>$dataProvider,
[b]'model' => $model,[/b]
));
}
I have bolded that line for a reason… Moving on to index.php in the view, I have the following:
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
and then I get an:
Undefined variable: model
right before $form->errorSummary($model);
and I var_dumped the $model var right before that and the var exists… Any toughts?
i have figured this out in case there are others facing the same dilemma I will clear this for them:
It seams that you cannot pass $dataProvider and $model in render() method… one of this gets lost just remove $dataProvider and it will work…
If anyone knows exactly why this is happening, could you please inform us all?
Keith
(Kburton)
July 14, 2014, 8:56am
3
There should be no reason for that to happen. I suspect the problem is somewhere else. Are you trying to use the model in a grid that’s being fed by the data provider or anything?
Ares
(Draguna Ares)
July 14, 2014, 11:39am
4
I am not using dataProvider in index except for a zii widget
is this working?
$model = $this->loadModel(Yii::app()->user->id);
$this->render('index',array(
'dataProvider'=>$dataProvider,
'model' => $model,
));