/** * Deletes a product * * If no product ID is passed or if it does not match a valid product ID in the database, an error * message is generated. Otherwise the product is deleted and a success message is generated. In either * case the user is redirected to the products index. */ public function actionDelete() { testProject::setAlert('There was a problem with your request. Please try again.', 'error'); if (isset($_GET['value'])) { //check if ID is provided $model = items::model()->getByPK($_GET['value']); $name = $model->name; if ($model->delete()) { //attempt to delete the item testProject::setAlert('The item ' . $name . ' was deleted.', 'info'); } } $this->redirect('items/index'); }