Skip to content

Commit

Permalink
Fixing non output of flash messages from Scaffolds when controller is…
Browse files Browse the repository at this point in the history
… not using Sessions. Refs #64
  • Loading branch information
markstory committed Aug 31, 2009
1 parent 8be5de9 commit c0ba43c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cake/libs/controller/scaffold.php
Expand Up @@ -287,7 +287,8 @@ function __scaffoldSave($params = array(), $action = 'edit') {
$this->controller->Session->setFlash(sprintf(__('The %1$s has been %2$s', true), Inflector::humanize($this->modelClass), $success));
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(__('The %1$s has been %2$s', true), Inflector::humanize($this->modelClass), $success), $this->redirect);
$this->controller->flash(sprintf(__('The %1$s has been %2$s', true), Inflector::humanize($this->modelClass), $success), $this->redirect);
return $this->_output();
}
} else {
return $this->controller->_afterScaffoldSaveError($action);
Expand Down Expand Up @@ -336,23 +337,25 @@ function __scaffoldDelete($params = array()) {
$this->controller->Session->setFlash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)));
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)),
'/' . Inflector::underscore($this->controller->viewPath));
$this->controller->flash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)), '/' . Inflector::underscore($this->controller->viewPath));
return $this->_output();
}

if ($this->ScaffoldModel->del($id)) {
if (isset($this->controller->Session) && $this->controller->Session->valid() != false) {
$this->controller->Session->setFlash(sprintf(__('The %1$s with id: %2$d has been deleted.', true), Inflector::humanize($this->modelClass), $id));
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(__('The %1$s with id: %2$d has been deleted.', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
$this->controller->flash(sprintf(__('The %1$s with id: %2$d has been deleted.', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
return $this->_output();
}
} else {
if (isset($this->controller->Session) && $this->controller->Session->valid() != false) {
$this->controller->Session->setFlash(sprintf(__('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id));
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(__('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
$this->controller->flash(sprintf(__('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
return $this->_output();
}
}
} elseif ($this->controller->_scaffoldError('delete') === false) {
Expand Down

0 comments on commit c0ba43c

Please sign in to comment.