Monday, July 16, 2012

cakephp success is red?

"Why is all setFlash red? Can't we do a success in green?"

Well, yes, just change the successful to look like this.
 $this->Session->setFlash(__('The information has been saved'), 'default', array('class' => 'success'));

This assumes you're using cake's default css.

If, incidentally, you want to bake it ...
copy lib/Cake/Console/Templates/default/actions/controller_actions.ctp to app/Console/Templates/default/actions/controller_actions.ctp and make similar changes to "has been saved" entries (there are two?)

$this->Session->setFlash(__('The has been saved'), 'default', array('class' => 'success'));

incidentally, setting up this custom will break other bakes. If you want to keep the functionality, you can either copy "default/classes" and default/views" or 
ln -s /path/to/lib/Cake/Console/Templates/default/classes app/Console/Templates/default/classes
ln -s /path/to/lib/Cake/Console/Templates/default/views app/Console/Templates/default/views

(I recommend symlinks if possible just in case updates in the templates from source need to trickle down.) 

YMMV, hope it helps someone.

No comments:

Blog Archive