cakephp验证视图问题?

cakephp验证视图问题?,php,javascript,jquery,ajax,cakephp,Php,Javascript,Jquery,Ajax,Cakephp,第一篇文章是关于堆栈溢出的,所以我希望我做得对,我已经搜索过了,但是找不到我要找的东西 我是cakephp新手,对php也相当陌生。昨天,我可以毫无问题地启动并运行,并且可以将数据发送到我的数据库。今天我想用ajax进行验证,但我想我会暂时不使用ajax,因为我在显示验证错误时遇到了问题 验证是为前两个表单字段设置的,如下所示 <?php class people extends AppModel { public $name = 'people'; public $u

第一篇文章是关于堆栈溢出的,所以我希望我做得对,我已经搜索过了,但是找不到我要找的东西

我是cakephp新手,对php也相当陌生。昨天,我可以毫无问题地启动并运行,并且可以将数据发送到我的数据库。今天我想用ajax进行验证,但我想我会暂时不使用ajax,因为我在显示验证错误时遇到了问题

验证是为前两个表单字段设置的,如下所示

<?php 

class people extends AppModel
{
    public $name = 'people';
    public $useTable = 'people';

    public $validate = array(
        'firstName'=>array(
            'rule'=>'notEmpty',
            'message'=>'Enter You First Name'
            ),
        'secondName'=>array(
            'rule'=>'notEmpty',
            'message'=>'Enter Your Second/Family Name'
            ),
        );
}?>
而不是

echo $this->Js->submit('send', array(
'before'=>$this->Js->get('#sending')->effect('fadeIn'),
'success'=>$this->Js->get('sending')->effect('fadeOut'),
'update'=>'#success'));
然后我再也没有收到错误消息了,取而代之的是出现了一个气泡,上面写着“请填写此字段”,我确信这是jquery的问题,但我也不知道如何排除故障,这样bullbe就不会出现,而是显示了我想要的错误消息

提前感谢

两件事:

1) 使用大写字母作为类名。所以
人控制器
,等等

2) 在标准流正常工作之前,不要乱用Ajax。所以回到
$this->Form->submit('submit')

3) “必需”的工具提示是HTML5。由于您将验证设置为
notEmpty
,Cake添加了HTML5标记以使字段成为必需字段。修改您的
表单->创建
调用以暂时绕过该调用(如果需要,但它提供了更高效的客户端验证):


谢谢,我很感激,我没有使用CAP的原因是因为我的数据库字段不是CAP,我可以假设这没有什么区别吗?不,类名没有链接到数据库字段。模型类名链接到db表,但它们总是转换为小写。
    <div id="success"></div>
<h2> Fill in your profile details </h2>

    <?php 
echo $this->Form->create('people');

echo $this->Form->input('firstName');
echo $this->Form->input('secondName');
echo $this->Form->input('addressOne');
echo $this->Form->input('addressTwo');
echo $this->Form->input('city');
echo $this->Form->input('county');
echo $this->Form->input('country');
echo $this->Form->input('postCode', array(
        'label' => 'Zip Code',
    ));
echo $this->Form->input('dob', array(
        'label' => 'Date of birth',
        'dateFormat' => 'DMY',
        'minYear' => date('Y') - 70,
        'maxYear' => date('Y') - 18,
    ));
echo $this->Form->input('homePhone');
echo $this->Form->input('mobilePhone');
echo $this->Form->input('email', array(
        'type' => 'email'
    ));

$goptions = array(1 => 'Male', 2 => 'Female');
$gattributes = array('legend' => false);

echo $this->Form->radio('gender', 
    $goptions, $gattributes
    );

echo $this->Form->input('weight');
echo $this->Form->input('height');

$toptions = array(1 => 'Tandem', 2 => 'Solo');
$tattributes = array('legend' => false);

echo $this->Form->radio('trained',
    $toptions, $tattributes
    );

echo $this->Form->input('referedBy');

/*echo $this->Form->submit('submit');*/

echo $this->Js->submit('Send', array(

    'before'=>$this->Js->get('#sending')->effect('fadeIn'),
    'success'=>$this->Js->get('#sending')->effect('fadeOut'),
    'update'=>'#success'

    ));

echo $this->Form->end();
     ?>
     <div id="sending" style="display: none; background-color: lightgreen">Sending....           </div>

    <?php

echo $this->Html->script(
    'validation', FALSE); 
     ?>
echo $this->Form->submit('submit');
echo $this->Js->submit('send', array(
'before'=>$this->Js->get('#sending')->effect('fadeIn'),
'success'=>$this->Js->get('sending')->effect('fadeOut'),
'update'=>'#success'));
$this->Form->create('People', array('novalidate' => true));