i have a button on my Cgrid that serves as an update button, when i click it, It sends me to my with the following url:
http://localhost/Add...unt/update&id=1
Is there a way I can get the number of the id in my URL, so that I can use it in my update form?
Or is there another approach for updating a record using CFormModel
here is my button on CGrid:
array(
'class'=>'CButtonColumn',
'template'=>'{update}',
'header'=>'Action',
'buttons'=>array(
'update'=>array(
'url'=>'Yii::app()->createUrl(\'account/update\', array(\'id\'=>$data[\'AID\']))',
),
),
),
Page 1 of 1
Get Id In Url And Save It In A Variable
#2
Posted 21 January 2013 - 12:02 PM
Just use $id, provided that the model function has id as a parameter.
Yii does some magic behind the scenes.
Yii does some magic behind the scenes.
"Less noise - more signal"
#3
Posted 21 January 2013 - 04:22 PM
Your existing url would work if your action looks like this:
You could also use this:
Or plain PHP:
public function actionUpdate($id) {
...
}You could also use this:
$id = Yii::app()->request->getQuery('id');Or plain PHP:
$id = $_GET['id'];
Share this topic:
Page 1 of 1

Help














