Thursday, December 12, 2013

Customise authError message class

I'm looking for advice on how to customize the authError message class (I'm using Twitter Bootstrap, so would like to use the alert styles from Bootstrap).

In /Controller/AppController.php I have the following snippet:

public function beforeFilter() {
  //Set custom authError message if user tries to access a controller when not logged in
  $this->Auth->authError = __('You are not authorized to view this page.');
}
Which produces this HTML (class="message":

<div id="authMessage" class="message"> You are not authorized to view this page.</div>

What I'd like to output is this HTML (class="alert alert-danger"):
<div id="authMessage" class="alert alert-danger"> You are not authorized to view this page.</div>

Much thanks in advance.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: