【发布时间】:2009-11-26 05:53:26
【问题描述】:
如何在sfValidator中添加自定义错误信息,形式为
$this->setWidgets(array(
'name' =>new sfWidgetFormInput(),
'country' =>new sfWidgetFormChoice(array('choices' => CountriesPeer::getAllCountries())),
));
验证器
$this->setValidators(array(
'name' =>new sfValidatorString(array('required'=>true)),
'country' =>new sfValidatorChoice(array('choices' => array_keys(CountriesPeer::getAllCountries()))),
));
我想要一条自定义消息而不是必需的或无效的消息(例如“需要姓名”“请选择一个国家/地区”)。 我知道我们可以在呈现表单时设置自定义错误消息,但是我们可以在表单验证器中设置它吗??
【问题讨论】: