php - Update two models using yii x-editable -


so, i'm using extension: x-editable yii.

and i'm trying update 2 models in update() function.

i have 2 models:

realisasi.php

realisasideadline.php.

so when cell updated on table realisasi.php (one value in column t1701 in case), want function update corresponding value in column t1701 of table realisasideadline, using column no foreign key.

since haven't found example on google, made myself:

public function actionsimpanedit($kode) {     yii::import('editable.editablesaver');     $es = new editablesaver($_get['model']);  // 'modelname' classname of model updated     $es->update();      $es2 = realisasideadline::model()->findbypk($kode);//this i'm stuck     $es2['t1701'] = '1991-11-19';//this     $es->update();//and } 

this view.php:

array(         'name' => 't1701',         'value' => 'chtml::value($data,"hubtarget.t1701")=== "0"?"target nol":$data->t1701',         'header' => 'bkl selatan',         'class' => 'editable.editablecolumn',         'editable' => array(             'url' => $this->createurl('simpanedit', array('model' => 'realisasi', 'kode'=>'$data->no')),         )     ), 

what have missed? possible @ do? if not, there solution?

update it's not showing error. value in table realisasideadline doesn't change, 1 in realisasi does.

added comments original function can improve upon it. biggest issue code looking @ have no idea does.

public function actionsimpanedit($kode) {         yii::import('editable.editablesaver'); // should @ top of file         // love of god use descriptive variable names         $es = new editablesaver($_get['model']); // prefer have model actions argument         $es->update();          $es2 = realisasideadline::model()->findbypk($kode); // no idea model responsible         $es2['t1701'] = '1991-11-19'; // no idea attribute t1701 is, use descriptive names         $es->update();     } 

i have refactored bit. still have no idea ;/

public function actionsimpanedit($id, $model) {         $editablesaver = new editablesaver($model);         $editablesaver->update();          $deadline = realisasideadline::model()->findbypk($id);          if($deadline instanceof realisasideadline) {             $deadline->t1701 = '1991-11-19';             if(!$deadline->update()) {                 // went wrong             }         } else {             // not found         }     } 

going problem. caused realisasideadline model being not found or behavior or event preventing update.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -