CakePHP why am I getting this error?

Refresh

December 2018

Views

2k time

2

Here is the error message:

Warning (2): preg_match() [http://php.net/function.preg-match]: Delimiter must not be alphanumeric or backslash [CORE/cake/libs/model/model.php, line 2611]

This is happening when I call the following code from my controller:

$this->Account->save($this->data)

The model looks like this:

class Account extends AppModel 
{       
    var $validate = array(        
        'first_name' => array(
            'rule' => array('minLength', 1),
            'required' => true   
        ),
        'last_name' => array(
            'rule' => array('minLength', 1),
            'required' => true   
        ),
        'password' => array(
            'rule' => array('minLength', 8),
            'required' => true    
        ),        
        'email' => array(
            'emailRule1' => array(
                'rule' => 'email',
                'required' => true,
                'message' => 'You must specify a valid email address' 
            ),
            'emailRule2' => array(
                'rule' => 'unique',
                'message' => 'That email address is already in our system'     
            )
        )   
    );
}

I found a similar problem explained here

He solved it by changing required' => true to required' => array(true) I tried that for every occurange in my model but it did not fix the problem.

1 answers

7

Проблема заключалась в том, я назвал правило uniqueэто должно быть isUniqueвместо этого.

Я бы понял это гораздо быстрее с лучшим сообщением об ошибке.