9 responses to “Delimiter must not be alphanumeric or backslash [CORE\cake\libs\model\model.php, line 2202]”

  1. Kim Pomares

    Thank you for this. I am going through Apress’s book on CakePHP (Beggining CakePHP, From Novice to Professional) and their validation script had that very error. Fortunately for me a Google search on the error message, took me right here. In fact I will echo it here to help others find your explanation quickly.

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

  2. Jason Hardy

    Amen Kim!

    I too am going through the Apress book and ran in the error. I still wonder if this is a Cake bug… or just maybe a slight oversight in Apress.

  3. Jamie

    I was getting this very same error and it was driving me nuts. Thank you, thank you, thank you for this post clearing up the necessity for setting required as an array.

  4. ADmad

    You are getting the error because you are not creating the validate array properly. And what you are doing is a hack. You need to specify a ‘rule’ for each field. ‘required’ is NOT a rule. I suggest you re-read the manual http://book.cakephp.org/view/127/One-Rule-Per-Field

  5. Kym

    hey, thanks, helped me a lot

  6. mmhan

    Many fields of mine were lost when $this->save() is called only after half an hour I found that the fields that I’m left with is the field with ‘require’ => ‘true’ hack.

    I know better now how not to use this hack. LOL

  7. omabena

    I don’t know why that solves the problems, but it just works, btw i was using notempty rule, which it’s part of the manual.

  8. Souvik Sengupta

    try this:

    var $validate = array
    (
    ‘employee_name’=>array
    (
    ‘rule’=>’notEmpty’,
    ‘message’=>’Please give employee name’
    )
    );

    it worked for me…

  9. vangel

    thanks, you saved my time. i dont understand why the cookbook is not updated. I only see this in 1.3 version i downloaded a few days ago. In my older version on 1.3 stable this is not the case. just if it helps someone.

    Merged
    hmm on second thoughts i do agree with Admad but not completely. ‘required’ is a rule however the array key ‘rule’ must be specified with a ruleName http://book.cakephp.org/view/127/One-Rule-Per-Field . then this array hack is not needed. I found this because i have multiple validation rules and although your workaround is quite ok and it works, it will not always work. good job though.

Leave a Reply