public function executeDeleteSelected() { $this->selectedItems = $this->getRequestParameter('sf_admin_batch_selection', array()); try { foreach (ArticlePeer::retrieveByPks($this->selectedItems) as $object) { $object->delete(); } } catch (PropelException $e) { $this->getRequest()->setError('delete', 'Could not delete the selected Articles. Make sure they do not have any associated items.'); return $this->forward('validation', 'list'); } return $this->redirect('validation/list'); }
protected function executeBatchDelete(sfWebRequest $request) { $ids = $request->getParameter('ids'); $count = 0; foreach (ArticlePeer::retrieveByPks($ids) as $object) { $this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', array('object' => $object))); $object->delete(); if ($object->isDeleted()) { $count++; } } if ($count >= count($ids)) { $this->getUser()->setFlash('notice', 'The selected items have been deleted successfully.'); } else { $this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items.'); } $this->redirect('@article'); }