Update only the specific field in cakephp -
i have small problem. have table item_pictures has 6 fields img1 | img2 | img3 | ima4 | img5| store 5 images. means 1 row of batabases has 5 fields store path of images. wanna create kind of button next each image when user click it, update field of image making empty, thats want. want update or change 1 speciffic field. possible , if how??
thats code have comme far:
$this->form->postlink($this->html->tag('i', '', array('class' => 'glyphicon glyphicon-remove')), array('controller' => 'item_pictures','action' => 'delete_current_img', $item['item']['id'] .'-'. 'img'.$i .'-'. $pictures['img'.$i]) , array('escape' => false), __('are sure want delete image?'))
so want in controller grab variable , update row id => $item['item']['id'] , on column img.$i value $pictures['img'.$i], , make empty...
i think pretty close, cycle $i = 1 $i = 5 with
$item_picture_id = $item['item']['itempicture']['id'] //or something, im not sure how have done relations echo $this->form->postlink($this->html->tag('i', '', array('class' => 'glyphicon glyphicon-remove')), array('controller' => 'item_pictures','action' => 'delete_current_img', $item_picture_id, 'img'.$i) , array('escape' => false), __('are sure want delete image?'));
so example image 5 ($i = 5) should resolve url: item_pictures/delete_current_img/id/img5/
then controller have (very simple example):
public function delete_current_img($id,$field){ $this->itempicture->id = $id; $this->itempicture->savefield($field,''); //then go come $this->redirect(array('controller' => 'foo', 'action' => 'where_ever_the_delete_came_from')); }
hope helps!
Comments
Post a Comment