Phalcon 3.0; PHP 5.6 (nginx + fpm); OS: Debian 7.6
Does Flash Direct works correctly? I can't get it to output.
services.php (flash stuff):
use Phalcon\Flash\Direct as Flash;
use Phalcon\Flash\Session as FlashSession;
/**
* Register the flash service with the Twitter Bootstrap classes
*/
$di->setShared('flash', function () {
return new Flash(
[
'error' => 'alert alert-danger',
'success' => 'alert alert-success',
'notice' => 'alert alert-info',
'warning' => 'alert alert-warning',
]
);
});
/**
* Register the session flash service with the Twitter Bootstrap classes
*/
$di->setShared('flashSession', function () {
return new FlashSession(
[
'error' => 'alert alert-danger',
'success' => 'alert alert-success',
'notice' => 'alert alert-info',
'warning' => 'alert alert-warning',
]
);
});
Part of the controller that puts message(s) into flash service:
// Form is INVALID, forward to edit form, data preserved
if(!$form->isValid($this->request->getPost())) {
foreach($form->getMessages() as $message) {
$this->flash->error($message);
}
//var_dump($this->flash->output());die; // THIS OUTPUTS THE MESSAGE
$this->dispatcher->forward(
[
'action' => 'edit',
'params' => [0 => $planId],
]
);
return true;
}
View volt file (actually a template setTemplateAfter("general")
), general.volt:
{{ flash.output() }} // THIS DOES'T SHOW ANYTHING
{{ flashSession.output() }} //THIS SHOWS WHEN I USE $this->flashSession