1

我基本上是在尝试检查一个字段是否仅包含字符而不是字符串或整数尝试使用 custom() 方法返回正则表达式 true 或 false 但给出错误可能语法错误对于 cake 3 来说是全新的

  $validator
         ->requirePresence('field','create')
         ->notEmpty('field')
          ->add('field','custom', ['check' => 'field', 'regex' => ['A-Za-z']
            ['message' => 'chars only']);

在下面给出这个错误......

无法在字段“字段”的“默认”提供程序中调用方法“”

4

1 回答 1

-1

->add('field',[ 'custom' => [ 'check' => 'field', 'regex' => '/[A-Za-z ]/', 'message' => (__("只允许使用字母")), ] ] );

于 2021-06-14T10:57:13.617 回答