Bug #83392
closed
Flashmessage won't work correctly with $this->redirect in a controllerAction
Added by Dieter Porth almost 7 years ago.
Updated almost 7 years ago.
Description
I got the following problem.
@
if ( ... ) {
...
$this->addFlashMessage(
LocalizationUtility::translate(
'flash.ad.checkCompany.missingData.message',
'project'
) . "\n" . $error,
LocalizationUtility::translate(
'flash.ad.checkCompany.missingData.title',
'project'
),
AbstractMessage::ERROR,
false
);
// the following line will not trigger a flashmessage
// $this->redirect(null, null, null, ['err' => 'ad'], $this->settings['pids']['profileCompany']);
//
$this->redirect('edit', 'Company', null, ['err' => 'ad'], $this->settings['pids']['profileCompany']);
}
@
Sorry. Misclick.
here the full code
@
if ( ... ) {
$this->addFlashMessage(
LocalizationUtility::translate(
'flash.ad.checkCompany.missingData.message',
'project'
) . "\n" . $error,
LocalizationUtility::translate(
'flash.ad.checkCompany.missingData.title',
'project'
),
AbstractMessage::ERROR,
false
);
// This won't show flashmessages
// $this->redirect(null, null, null, ['err' => 'ad'], $this->settings['pids']['profileCompany']);
//
$this->redirect('edit', 'Company', null, ['err' => 'ad'], $this->settings['pids']['profileCompany']);
}
@
- Status changed from New to Closed
- Assignee set to Stephan Großberndt
If you add a FlashMessage with the last parameter being FALSE
you define that message not to be stored in session. When the request ends, it is discarded. As redirect
starts a new request there is no message to display. Either set the last parameter to TRUE
or use forward
instead of redirect
.
Please use the channel #typo3-cms on Slack or StackOverflow to ask questions about your implementations, this is the core bugtracker for actual bugs in TYPO3 core.
- Description updated (diff)
The redirect in the comment won't show the flashmessage. That works correct and I have had a wrong idea.
But the current 'redirect' in the uncommented line shows the flashmessage. I think, the second line with the redirect is a bug.
P.S.
Thanks for your tipp on slack. I don't use activly slack or other chat-programm for everyday communication, because that tools are too chaotic and needs too much attention of mine.
Also available in: Atom
PDF