php - Show validation message when rule triggered -


so if have following validation rule in forward model

    public $validate = array(     'url' =>array(         'rule' => 'url',         'message' => 'please supply valid url.'     ) ); 

and want display message in flash how achieve that?

i have tried following:

        $new_forward = $this->request->data;         $this->forward->create();         $this->session->setflash($this->forward->save($new_forward)); 

also tried no result

$this->session->setflash($this->modelname->validationerrors); 

you can using below sample code,

$this->forward->create(); if ($this->forward->save($this->request->data)) {     $this->session->setflash(__('the forward has been saved', true),'flash_success');     $this->redirect(array('controller' => 'forwards','action' => 'index')); } else {     $this->session->setflash(__('the forward not saved. please, try again.', true),'flash_error'); } 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -