在yii中编辑特定记录

I have a view section in my project,and using CGridView to list all the data from table,also have an edit and delete option within the grid to edit and delete specific row.

I am stuck with the edit section.I am working on how to get a specific row data dispalyed in editjob.php,I have done a few things,but no use.My codes are as follows,

In my view job section using CgridView,

  'buttons' =>array('update'=>array(

     'label'=>'edit',
     'url'=>'Yii::app()->controller->createUrl("UpdateJob",array("id"=>$data["id"]))',

   ))

In Model UpdateJob:

public function edit()
{

 $criteria=new CDbCriteria;

 $criteria->find('id','Admin',true);

 return new CActiveDataProvider('viewjob', array(
    'criteria'=>$criteria,
   // 'sort'=>array(
       // 'defaultOrder'=>'key_skills ASC',
   // ),
));

in controller:

public function actionUpdateJob()
{ 

     if(isset($_GET['id']))
    {
        $id=$_GET['id'];
    }

     $model = new UpdateJob('edit');
     $params = array('model' => $model,'id' => $id  //passing the id like this
    );



    $this->render('update', $params);
}

And finaly in view written something like ,but showing error

   <div class="row">
        <?php echo $form->labelEx($model,'Company Name'); ?>
        <?php echo Chtml::textField('posted_by',UpdateJob::model()->FindByPk($model->id)->posted_by);  ?>
        <?php echo $form->error($model,'posted_by'); ?>
    </div>

am I on right track.

Youre loading a fresh model instead of fetching an existing one. Replace this line:

$model = new UpdateJob('edit');

By this line:

$model = UpdateJob::model()->findByPk($id);

To save the data you do this:

if(isset($_POST['UpdateJob'])) {
    $model->scenario='edit';
    $model->attributes=$_POST['UpdateJob'];
    if($model->save())
        $this->redirect(array('admin');
}