CakePHP why am I getting this error?


December 2018


2k time


Here is the error message:

Warning (2): 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:


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


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

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