cakePHP doğrulama

1 Cevap php

Ben bir cakePHP proje üzerinde çalışıyorum ve benim veri doğrulama kurdunuz. I var sorun CakePHP çekirdek / model bir hata almaya devam olmasıdır.

The error is: Notice (8): Undefined offset: 0 [CORE/cake/libs/model/model.php, line 2435]

                        if (is_array($validator['rule'])) {
                        $rule = $validator['rule'][0];

Benim doğrulama kuralları şöyle:

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

Herhangi bir yardım çok takdir.

1 Cevap

Senin sorunun kural sözdizimi şöyledir:

array('maxLength' => 80)

Sadece diğer kurallar gibi, bu ,, değil =>: array('maxLength', 80).


BTW, benim şehrim can olması uzun: http://en.wikipedia.org/wiki/Krung Thep Mahanakhon Amon Rattanakosin Mahinthara... ;-)