我試圖在Kohana 3(Orm Model)中添加驗證消息。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 ()))
我沒有得到任何驗證消息,就這輸出以上... 任何ideia?謝謝。
非常感謝。問題解決了! – thom 2010-12-15 14:34:14