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
Post a Comment