Hi,

Sometimes I feel limited by "flash messages", as I found developers to
write code such as :

(in action context)
$this->getUser()->setFlash('success', 'Update successful');
...
$this->getUser()->setFlash('error', 'An error has occured... ');
...
$this->getUser()->setFlash('info', $sn_results.'results found');
....
etc.

(in top of many templates)
<?php if ($sf_user->hasFlash('success')): ?>
  <p class="success"><?php echo $sf_user->getFlash('success') ?></p>
<?php endif; ?>
<?php if ($sf_user->hasFlash('error')): ?>
  <p class="error"><?php echo $sf_user->getFlash('error') ?></p>
<?php endif; ?>
<?php if ($sf_user->hasFlash('info')): ?>
  <p class="info"><?php echo $sf_user->getFlash('info') ?></p>
<?php endif; ?>

In the templates, there is obviously code repetition.

Even worse, imagine that you want to "flash" the user with two error
messages, you have to do some ugly tricks such as :
$this->getUser()->setFlash('error_xxx', 'An error XXX has occured...
');
$this->getUser()->setFlash('error_yyy', 'An error XXX has occured...
');

BTW, I've found the chosen word "flash" a bit confusing (clearly with
Adobe's Flash technology), especially for web searches.


So I've ended up by writing my own "custom" flash messaging, storing
messages in a simple array, allowing me to do things such as :

(action)
$this->getUser()->addNote('error', 'An error has occured');
...
$this->getUser()->addNote('success', 'Update successful');
...

(template)
use_helper('Notes');
get_user_notes();

=> get_user_notes() generates the HTML <p class="xxx">xxxx</p> for
each message, and empties the message array from the user session.

Could Symfony users / developers be interested by this approach ? Do
you think that this kind of behavior be available in future Symfony
versions ?

Regards,
Maxime

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to