cakePHP validation
我正在开发cakePHP项目并设置了我的数据验证。 我遇到的问题是我不断从cakePHP的核心/模型中得到错误。
错误是:
注意(8):未定义的偏移量:0 [CORE / cake / libs / model / model.php,第2435行]
1 2 |
我的验证规则如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | var $validate = array( 'name' => array( 'rule' => array('maxLength' => 80), 'required' => true, 'message' => 'Please enter your name' ), 'address1' => array( 'rule' => array('maxLength' => 80), 'required' => true, 'message' => 'You forgot your address' ), 'address2' => array( 'rule' => array('maxLength' => 80), 'message' => 'Your address can\'t be that long?' ), 'city' => array( 'rule' => array('maxLength' => 80), 'required' => true, 'message' => 'Your city can\'t be that long?' ), 'zip' => array( 'rule' => array('postal', null, 'us'), 'required' => true, 'message' => 'Your zip code is not in the corect format.' ), 'phone' => array( 'rule' => array('phone', null, 'us'), 'required' => true, 'message' => 'Your phone number is not in the corect format.' ), 'email' => array( 'rule' => 'email', 'required' => true, 'message' => 'Please enter a valid email address.' ), 'seats' => array( 'rule' => 'numeric', 'required' => true, 'message' => 'You forgot to let us know how many seats you need. If you will not be attending please enter a zero (0)' ), 'seat_with' => array( 'rule' => array('maxLength' => 80), 'message' => 'Please keep this field below 80 charcters.' ), 'cc_name' => array( 'rule' => array('maxLength' => 80), 'required' => true, 'message' => 'Did you forget something?' ), 'cc_number' => array( 'rule' => array('cc', 'all', false, null), 'required' => true, 'message' => 'Your credit card number is not in the correct format.' ), 'cc_expiration' => array( 'rule' => array('date', 'my'), 'required' => true, 'message' => 'The correct answer will be in the following format MM/YYYY' ), 'cc_cvv' => array( 'rule' => 'numeric', 'required' => true, 'message' => 'Numbers only please.' ) ); |
任何帮助深表感谢。
您的问题在于规则语法:
1
就像你的其他规则一样,它是
顺便说一句,我的城市可以那么长:http://en.wikipedia.org/wiki/Krung Thep Mahanakhon Amon Rattanakosin Mahinthara ...... ;-)