cakephp 2.6 - I'd like to redirect and setFlash messages -


i tried cakephp blog tutorial (http://book.cakephp.org/2.0/en/getting-started.html) on , on again.

but code can't redirect , not working setflash messages when adding posts.

could tell me what's wrong code , how fix this?

i'm thinking mamp setting wrong because adding process working when refreshing index page.

  • mac
  • mamp

here code.

<?php //file: /app/controller/postscontroller.php class postscontroller extends appcontroller {     public $helpers = array('html', 'form', 'session');     public $components = array('session');      public function index() {         $this->set('posts', $this->post->find('all'));     }      public function view($id = null) {         if(!$id) {             throw new notfoundexception(__('invalid post'));         }          $post = $this->post->findbyid($id);         if(!$post) {             throw new notfoundexception(__('invalid post'));         }         $this->set('post', $post);     }      public function add() {         if($this->request->is('post')) {             $this->post->create();             if($this->post->save($this->request->data)) {                 $this->session->setflash(__('your post has been saved.'));                 return $this->redirect(array('action' => 'index'));             }             $this->session->setflash(__('unable add post.'));         }     } } ?> 


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -