Slim does not 'flash' error data \

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Darrel
Forum Commoner
Posts: 33
Joined: Fri Oct 10, 2014 2:30 am

Slim does not 'flash' error data \

Post by Darrel »

I'm having some issues displaying the flash variable via Slim and Twig. When I POST to slim it renders the page without the 'error'. Thoughts?

$app->get('/getintouch', function() use ($app, $settings) {
$app->render('getintouch.html');
});

$app->post('/getintouch', function() use ($app, $settings) {
$name = $app->request->post('name');
if (strlen($name) < 2) {
$app->flash('error', 1);
$app->redirect('/getintouch');
}
});
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Slim does not 'flash' error data \

Post by requinix »

You can't show a message on the page and redirect away from that page at the same time.

From what I can tell you shouldn't be redirecting at all. Show the error message and redisplay the form.
Post Reply