cakephp - Delete multiple rows by ticking Checkbox -
cakephp - Delete multiple rows by ticking Checkbox -
how delete multiple rows checking checkbox? have table of records, , i'd to delete multiple rows @ once.
this my deleteselected function:
updated
public function order() { if(!empty($this->data)) { //if @ lesst 1 check box selected if (isset($this->data) && !empty($this->data['order_id'])) { $selectedreferences = $this->data['order_id']; $flagreferenceadded = false; foreach ($selectedreferences $singlereference) { //new delete $this->order->id = $singlereference; $this->order->delete(); //new delete } //after delete $this->session->setflash( __('your record deleted.') ); homecoming $this->redirect(array('')); } else{ echo "select @ to the lowest degree 1 order."; } } and in view.
<?php echo $this->form->create('order',array('url' => array('controller' => 'admin', 'action' => 'order'))); ?> <table class="table table-bordered table-hover"> <th>name</th> <th>email</th> <th>phone</th> <th>view</th> <th>delete</th> <thead> </tr> </thead> <tbody> <?php foreach ($order $orders): ?> <tr> <td><?php echo $orders['order']['varfullname']; ?></td> <td><?php echo $orders['order']['varemailid']; ?></td> <td><?php echo $orders['order']['varphone']; ?></td> <td> <?php echo $this->html->link('', array('controller' => 'orders', 'action' => 'view', $orders['order']['id']), array('title'=>'view','class' => 'fa fa-search'));?> </td> <td><input type="checkbox" name="order_id[]" value ="<?php echo $orders['order']['id'];?>" hiddenfield = "false"> </td> </tr> <?php endforeach; ?> </tbody> </table> </br> <? echo $this->form->end('deleteselected'); ?> </div> </div> </br> </div> <!-- /.row --> after using below reply delete selected working fine
use in ctp
//in ctp along each record utilize checkbox integration . dont utilize checkbox code u used.
<input type="checkbox" name="order_id[]" value ="<?php echo $referencesingle['order']['id'];?>" hiddenfield = "false"> //in controller
if(!empty($this->data)) { //if @ lesst 1 check box selected if (isset($this->data) && !empty($this->data['order_id'])) { $selectedreferences = $this->data['order_id']; $flagreferenceadded = false; foreach ($selectedreferences $singlereference) { //new delete $this->order->id = $singlereference; $this->order->delete(); //new delete } //after delete $this->session->setflash( __('your record deleted.') ); homecoming $this->redirect(array('')); } else{ echo "select @ to the lowest degree 1 order."; } } update
use above code in index method ,dont create deleteall method.
or create <form action deleteall
like echo $this->form->create('searchcourse',array('url' => array('controller' => 'courses', 'action' => 'index')));
update proper workflow refer : paperwork , algorithm ,before coding sir.
cakephp cakephp-2.3 delete-row
Comments
Post a Comment