cakephp 2.0 flash messages not displaying -


i'm trying display flash messages errors not displaying tried , researched didnt come solution, im quite new cake beer me thnks carts

userscontroller

   public function add() {     if ($this->request->is('post')) {              $this->user->create();             if ($this->user->save($this->request->data)) {             $this->session->setflash(__('the user has been created'));             $this->redirect(array('action' => 'index'));             } else {             $this->redirect(array('controller'=>'pages',  'action' => 'home'));             $this->session->setflash(__('the user not created. please, try again.'));              }              }           } 

default.ctp

     <div id="">     <?php echo "flash:" ?>     <?php  echo $this->session->flash();?> 

element/failure

 <div class="flash flash-failure">  <?php echo h($message); ?>  </div> 

view file

form->create('user', array('action' => 'add'));?>

    <div class="firstname">         <?php echo $this->form->input('firstname', array('class' => 'input01'));?>      </div>       <div class="lastname">         <?php echo $this->form->input('lastname', array('class' =>'input02'));?>      </div>     <div class = "firstname">          <?php echo $this->form->input('location', array('class' => 'input03'));?>      </div>     <div class="firstname">         <?php echo $this->form->input('username', array('class' =>'input03'));?>      </div>     <div class="email">         <?php echo $this->form->input('email', array('class' => 'input03'));?>      </div>      <div class="lastname">         <?php echo $this->form->input('password',array('class' => 'input02'));?>      </div>      <div class="email">     <?php   echo $this->form->input('password_confirm', array('label' => 'confirm password *', 'maxlength' => 255, 'title' => 'confirm password', 'type'=>'password', 'class' =>'input03'));?>       </div> 

if want set flash custom element, need using syntax.

$this->session->setflash('error occured','failure'); 

the second parameter custom element contain flash html.

you may read more details of session flash here : http://book.cakephp.org/2.0/en/core-libraries/components/sessions.html

edited: check if code enters is('post'), dont have full form , don't know form send method you're using


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -