Skip to content

Commit c0ba43c

Browse files
committed
Fixing non output of flash messages from Scaffolds when controller is not using Sessions. Refs #64
1 parent 8be5de9 commit c0ba43c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

cake/libs/controller/scaffold.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ function __scaffoldSave($params = array(), $action = 'edit') {
287287
$this->controller->Session->setFlash(sprintf(__('The %1$s has been %2$s', true), Inflector::humanize($this->modelClass), $success));
288288
$this->controller->redirect($this->redirect);
289289
} else {
290-
return $this->controller->flash(sprintf(__('The %1$s has been %2$s', true), Inflector::humanize($this->modelClass), $success), $this->redirect);
290+
$this->controller->flash(sprintf(__('The %1$s has been %2$s', true), Inflector::humanize($this->modelClass), $success), $this->redirect);
291+
return $this->_output();
291292
}
292293
} else {
293294
return $this->controller->_afterScaffoldSaveError($action);
@@ -336,23 +337,25 @@ function __scaffoldDelete($params = array()) {
336337
$this->controller->Session->setFlash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)));
337338
$this->controller->redirect($this->redirect);
338339
} else {
339-
return $this->controller->flash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)),
340-
'/' . Inflector::underscore($this->controller->viewPath));
340+
$this->controller->flash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)), '/' . Inflector::underscore($this->controller->viewPath));
341+
return $this->_output();
341342
}
342343

343344
if ($this->ScaffoldModel->del($id)) {
344345
if (isset($this->controller->Session) && $this->controller->Session->valid() != false) {
345346
$this->controller->Session->setFlash(sprintf(__('The %1$s with id: %2$d has been deleted.', true), Inflector::humanize($this->modelClass), $id));
346347
$this->controller->redirect($this->redirect);
347348
} else {
348-
return $this->controller->flash(sprintf(__('The %1$s with id: %2$d has been deleted.', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
349+
$this->controller->flash(sprintf(__('The %1$s with id: %2$d has been deleted.', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
350+
return $this->_output();
349351
}
350352
} else {
351353
if (isset($this->controller->Session) && $this->controller->Session->valid() != false) {
352354
$this->controller->Session->setFlash(sprintf(__('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id));
353355
$this->controller->redirect($this->redirect);
354356
} else {
355-
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);
357+
$this->controller->flash(sprintf(__('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
358+
return $this->_output();
356359
}
357360
}
358361
} elseif ($this->controller->_scaffoldError('delete') === false) {

0 commit comments

Comments
 (0)