我正在尝试在 Kohana 3(Orm 模型)中添加验证消息。
类/模型/cliente.php
<?php defined('SYSPATH') or die('No direct script access.');
class Model_Cliente extends ORM {
protected $_table_name = 'clientes';
protected $_primary_key = 'id';
protected $_has_one = array('loja' => array());
protected $_rules = array(
'responsavel' => array('not_empty' => array(), 'min_length' => array(3)),
'email' => array('not_empty' => array(), 'email' => array()),
'telefone' => array('regex' => array('/^(\(\d{2}\)|\d{2})[ -]?\d{4}[ -]?\d{4}$/'))
);
}
?>
消息/cliente.php
<?php defined('SYSPATH') or die('No direct script access.');
return array(
'responsavel' => array(
'not_empty' => 'O nome do responsável não pode ficar em branco.',
'min_length' => 'O nome do responsável deve conter 3 caracteres ou mais.'
)
);
?>
输出:
Array ( [responsavel] => Array ( [0] => not_empty [1] => Array ( ) ) [email] => Array ( [0] => not_empty [1] => Array ( ) ) )
我没有收到任何验证消息,只是上面的这个输出......有什么想法吗?谢谢你。