twb
(Jianfeng82)
January 16, 2011, 4:35pm
1
For my controller, say actionUpdate(), I added a variable to be passed to the _form.
$this->render('update',array(
'model'=>$model,
'myvar'=>true,
));
I read that in the form, I can access the variables directly, such as
$model->
but there is no $myvar defined.
Did I misunderstand something??
tri
(tri - Tommy Riboe)
January 16, 2011, 5:25pm
2
For my controller, say actionUpdate(), I added a variable to be passed to the _form.
$this->render('update',array(
'model'=>$model,
'myvar'=>true,
));
…
but there is no $myvar defined.
…
It should be there. Perhaps you’ll need to pass it along, if in case you want to access it from a subview (partial).
/Tommy
For my controller, say actionUpdate(), I added a variable to be passed to the _form.
$this->render('update',array(
'model'=>$model,
'myvar'=>true,
));
I read that in the form, I can access the variables directly, such as
$model->
but there is no $myvar defined.
Did I misunderstand something??
Did you mean that you’re trying to pass a variable into a Form, as in a form model class? If so, that is not the way to do it. What you are doing is passing a boolean variable called ‘myvar’ into the view called ‘update’. As was already pointed out, you should be able to access $myvar in the ‘update’ view (update.php).
twb
(Jianfeng82)
January 17, 2011, 1:39am
4
Did you mean that you’re trying to pass a variable into a Form, as in a form model class? If so, that is not the way to do it. What you are doing is passing a boolean variable called ‘myvar’ into the view called ‘update’. As was already pointed out, you should be able to access $myvar in the ‘update’ view (update.php).
Sorry I do not quite understand… What I am trying to do is…
under controllers/UserController.php, under actionUpdate(), I modified the render to become as below. myvar could be a boolean or string or anything…
$this->render('update',array(
'model'=>$model,
'myvar'=>true,
));
Then in the views/user/_form.php I am trying to get $myvar but it was not ‘available’. Can I even get $myvar in _form.php?
twb:
Sorry I do not quite understand… What I am trying to do is…
under controllers/UserController.php, under actionUpdate(), I modified the render to become as below. myvar could be a boolean or string or anything…
$this->render('update',array(
'model'=>$model,
'myvar'=>true,
));
Then in the views/user/_form.php I am trying to get $myvar but it was not ‘available’. Can I even get $myvar in _form.php?
In the code you are rendering the view ‘update’ which refers to ‘views/user/update.php’. Where in code are you rendering ‘_form’? That is where you need to pass ‘myvar’ if you want to access it in ‘_form.php’.
jayrulez
(Waprave)
January 17, 2011, 2:58am
6
For my controller, say actionUpdate(), I added a variable to be passed to the _form.
$this->render('update',array(
'model'=>$model,
'myvar'=>true,
));
I read that in the form, I can access the variables directly, such as
$model->
but there is no $myvar defined.
Did I misunderstand something??
from youe view update.php wher eyou have $this->renderPartial(’_form’,…)
you need to pass the variables to the renderPartial method where i place … like array(‘model’=>$model, ‘myvar’=>$myvar)
so it should look like
$this->renderPartial(’_form’, array(‘model’=>$model, ‘myvar’=>$myvar))