开发者

cakephp validation problem: Delimiter must not be alphanumeric or backslash

开发者 https://www.devze.com 2023-02-19 01:24 出处:网络
I am just starting on cakePHP and I came across this problem Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [CORE/cake/libs/model/model.php, line 261

I am just starting on cakePHP and I came across this problem

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

I get that when I try and add/edit a post. It's getting triggered by this validation code:

var $validate = array(
        'title' => array(
            'title_not_blank' => array(
                'rule' => 'nonEmpty',
                'message' => 'This post is missing a title'
            ),
            'title_unique' => array(
                'rule' => 'isUnique',
                'message' => 'A post with this title already exists'
开发者_C百科            )
        ),
        'body' => array(
            'body_not_blank' => array(
                'rule' => 'notEmpty',
                'message' => 'Post is missing its body'
            )
        )
    );

I have no idea what to do? Any help?


You know what? You are doing validation rules/code correctly (even with multiple rules per field). The only cause of your problem is that you are writing nonEmpty instead of notEmpty (notice the t) in you first rule.

Yeah, I know how frustrating these minor things can be. Perhaps this is why we coders eventually develop OCD. :D

0

精彩评论

暂无评论...
验证码 换一张
取 消