2013-03-05 53 views
0

我是cakephp的新手,並且正在嘗試在其中構建應用程序。我有一些文本框,我希望對它們進行驗證。我在cakephp.org中關注cakephp教程並做了以下工作,但我無法看到textfields附近的驗證消息。以下是我的代碼:cakephp驗證郵件不顯示

CTP:

<?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' 
); 

這裏我收到錯了嗎?我如何解決它?

+0

參考http://book.cakephp.org/2.0/en/index.html – 2013-03-05 05:17:30

回答

0

您已經使用逗號在dropat

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

刪除它,仍然不能正常工作 – z22 2013-03-05 05:21:23

+0

你可以添加.ctp文件的完整代碼嗎? – 2013-03-05 05:50:05

0

可以使用此 形式 - >文本( 'Rideoffer.PickFrom', 陣列( '類'=> '地址文本', 「值'=> $ dropFrom, 'error'=>'不能將該字段留空。')); ?>