Reputation: 357
I'm total newbie on Yii. Professor basically asks us to make school project having shown us three things to do in Yii. Let's observe two classes I have, their models being: StudProg and NivoStudija. What I want is to pass attribute 'naziv' from nivoStudija/admin to studProg/admin, because when I click on a particular item nivoStudija/admin, studProg/admin is shown and I want to use this variable there. So I pass argument like this in one of my CGridView widget's items: CHtml::link($data->naziv, array("studProg/admin", "nivo_naziv" => $data->naziv))
It opens up studProg/admin and I see URL like this: http://localhost/pmf/index.php?r=studProg/admin&nivo_naziv=Osnovne+studije
My problem is: How do I get this nivo_naziv thing to use it in studProg/admin ? Thanks in advance.
Upvotes: 1
Views: 2276
Reputation: 713
In Yii if you want to access get and post parameter, you can use getParam function like this.
Yii::app()->request->getParam('nivo_naziv);
http://www.yiiframework.com/doc/api/1.1/CHttpRequest
Upvotes: 0
Reputation: 133400
For Yii1 you need the equivalent code
$my_nivo_naziv = Yii::app()->request->getQuery('nivo_naziv);
Upvotes: 1
Reputation: 1143
I'm assuming that you are using Yii2.
Then you can get the URL parameter with:
Yii::$app->getRequest()->getQueryParam('nivo_naziv');
Try this for Yii1:
Yii::app()->getRequest()->getParam('nivo_naziv');
Upvotes: 0