我尝试了所有方法,但它蛋糕 php 数据验证不起作用。你能告诉我什么是错误的部分吗?我添加了所有类型的验证,但表单仍然保存没有验证数据!
我的模型:
class contacts extends AppModel
{
    public $name = 'contact';
    public $useTable='contacts';    
    public $validate=array(
        'name' => array(
            'requierd'=>array(
                'rule'=>array('Not empty'),
                'message' => 'A username is required'
        )
        )
    );
}
我的控制器
class ContactsController extends AppController
{
    public $helpers=array('Html','Form');
    public $components=array('session','Email');
    public function index()
    {
        if($this->request->is('post'))
        {
             $this->Contact->create();
            if($this->Contact->save($this->request->data))
            {
                $this->Session->setFlash('Thank you we will contact you soon');
                $this->redirect(array('action'=>'index'));
            }
            else
            {
                $this->Session->setFlash('Unable to send your message.');
            }
        }
    }
}
我的观点:
echo $this->Form->create('Contact');
echo $this->Form->input('name');
echo $this->Form->input('email');
echo $this->Form->input('subject');
echo $this->Form->input('message',array('rows' => '3'));
//echo $this->Form->checkbox('Send me a coppy');
echo $this->Form->end('Send');