我想在表中插入记录。为此,我有模型、视图和控制器。我的代码中的一切都运行良好,但我的验证模型代码没有显示任何验证消息。我该怎么办?我在下面给出代码:
我的控制器代码:
public function send_money()
{
$this->layout='agent';
$this->Agent->create();
$this->Agent->set($this->data);
if(empty($this->data) == false)
{
//$this->Agent->saveAll($this->data['Agent'], array('validate' => 'only')); //This code Id New
$this->Agent->saveAll($this->data['Agent']);
$this->Session->setFlash('Information Added Successfully.');
$this->redirect('send_money');
}
else
{
$this->set('errors', $this->Agent->invalidFields());
}
}
And My Model Code is :
App::uses('AppModel', 'Model');
/**
* Admin Login Model
*
*/
class Agent extends AppModel
{
public $name='Agent';
public $usetables='agents';
public $validate = array(
'contact' =>array(
'rule' => 'notEmpty', // or: array('ruleName', 'param1', 'param2' ...)
'allowEmpty' => false,
'message' => 'Please Enter Contact No.'
),
'name' =>array(
'rule' => 'notEmpty', // or: array('ruleName', 'param1', 'param2' ...)
'allowEmpty' => false,
'message' => 'Please Enter Name.'
),
'email_add' =>array(
'rule' => 'email', // or: array('ruleName', 'param1', 'param2' ...)
'allowEmpty' => false,
'message' => 'Please Enter Valid Email.'
),
);
}