简体   繁体   English

yii中的基本编辑操作

[英]Basic edit operation in yii

I have used CgridView which list all the data from my table 'Jobs',also have an edit and delete for each row.Which has been implemeted using prebuilt template in yii.I tried few things,but it not working.My first aim is to display that particular row data in edit form. 我使用了CgridView ,它列出了表'Jobs'中的所有数据,还对每一行进行了编辑和删除。这是使用yii中的预构建模板实现的。我尝试了一些尝试,但没有用。我的首要目标是以编辑形式显示该特定行数据。

My codes are as follows: 我的代码如下:

The model corresponding is,UpdateJob.php. 对应的模型是UpdateJob.php。

/*Model*/


 public function edit() {


        $criteria = new CDbCriteria;

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

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


/*Contoller*/


public function actionUpdateJob()
{ 


     if(isset($_GET['id']))     //Is it the right way //
    {
        $id=$_GET['id'];
    }

     $model = new UpdateJob('edit'); 
     $params = array('model' => $model,'id' => $id
    );
    $this->render('update', $params);

}


/*VIEW*/ Have just tried to show the data as follows.

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

</div>

Thats it.. 而已..

How to just display the row of a particular id. 如何仅显示特定ID的行。 For the time being I don't want to update it. 目前,我不想更新它。 Please Help 请帮忙

this will be done through js 这将通过js完成

$(gridID).yiiGridView('getSelection') should be your start $(gridID).yiiGridView('getSelection')应该是你的开始

read http://www.yiiframework.com/doc/api/1.1/CGridView 阅读http://www.yiiframework.com/doc/api/1.1/CGridView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM