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]

    September 3, 2008 at 6:49 pm |
  2. 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.

    September 18, 2008 at 6:33 pm |
  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.

    September 25, 2008 at 8:53 am |
  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

    November 18, 2008 at 1:06 am |
  5. Kym:

    hey, thanks, helped me a lot

    January 7, 2009 at 7:54 pm |
  6. 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

    July 22, 2009 at 7:27 am |
  7. 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.

    April 28, 2010 at 5:40 pm |
  8. Souvik Sengupta:

    try this:

    var $validate = array
    ‘message’=>’Please give employee name’

    it worked for me…

    May 27, 2010 at 12:19 pm |
  9. 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.

    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 . 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.

    June 12, 2010 at 8:24 am |
  10. Nik:

    Brilliant- thanks! .. Worked for me :)

    July 26, 2010 at 10:22 pm |
  11. Michel:

    Fixed my problem. Thanks.

    August 7, 2010 at 10:58 am |
  12. “notEmpty” rule solves the problem neat and tidy.
    Thanks Souvik.

    August 25, 2010 at 2:39 am |
  13. Laz:

    Thanks for the explanation of this error, it finally made sense to my tired brain and helped me fix the problem!

    March 19, 2011 at 10:09 pm |
  14. RichieRich:

    Thanks for this, helped me out.

    top result for:

    Delimiter must not be alphanumeric or backslash cakephp

    September 9, 2011 at 8:29 am |

Leave a Reply

You must be logged in to post a comment.