0

我是 cakephp 新手,正在尝试在其中构建一个应用程序。我有一些文本字段,我希望对它们进行验证。我在 cakephp.org 中关注 cakephp 教程并执行了以下操作,但我在文本字段附近看不到验证消息。以下是我的代码:

cp:

   <?php echo $this->Form->text('Rideoffer.PickFrom', 
                                                array('class' => 'address-text',
                                                    'value' => $dropFrom));  ?>

模型:

public $validate = array(
         'PickFrom' => array(
        'rule' => 'notEmpty',
        'message' => 'Cannot leave this field blank.'
    ),
    //'PickFrom' => 'notEmpty',
    'DropAt' => 'notEmpty',
   // 'born'  => 'date'
);

我哪里错了?我该如何解决?

4

2 回答 2

0

你可以使用这个Form->text('Rideoffer.PickFrom', array('class' => 'address-text', 'value' => $dropFrom, 'error'=>'Cannot leave this field空白。') ); ?>

于 2013-03-05T14:39:27.067 回答
0

您在 dropat 中使用了逗号

public $validate = array(
         'PickFrom' => array(
        'rule' => 'notEmpty',
        'message' => 'Cannot leave this field blank.'
    ),
    //'PickFrom' => 'notEmpty',
    'DropAt' => 'notEmpty'
   // 'born'  => 'date'
);
于 2013-03-05T05:19:24.997 回答