0

I've got a problem showing $this->Session->flash();. In my controller just for testing purpouse I set a session flash and then I throw a new Exception, but in my view the session flash is not showing.

I'm throwing an error because I'm using ajax to submit a form and dynamically uptade my view. Is there a way to upcome this without droping the ajax?.

edit

in my controller

  $this->Session->setFlash(__('Error, try again'), 'flash_foundation_good');
  throw new InsertException(__('Error, try again.'));

in my layout

        <div class="inner-wrap">
            <?php echo $this->Session->flash(); ?>
            <?php echo $this->fetch('content'); ?>

            <a class="exit-off-canvas"></a>
        </div>

In my view

As I said before, I'm using an ajax call here is a little of it. (just the submit button)

echo $this->Js->submit('Save', 
            array( 
                'id'=>'submit-ajax',
                'update' => '#myModal', 
                'before'=>'before();',
                'complete'=>'reset();',
                'success'=>'success();',
                'error'=>'nope(XMLHttpRequest);',
                'div'=>array('class'=>'row'), 
                'class'=>'button', 
                'style'=>'margin: 0 auto; display: block;' 
                )
            );
        echo $this->Js->writeBuffer();

I just work around the session flash using the error method, and dynamically show what I want, but still I want too know how to make appear the session flash ):

0 Answers0