如何sfValidator添加自定义错误消息,形式要在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()))),
));
,而不是必需的,或者无效的消息,我想自定义消息(如“是必需的名字” '请选择一个国家')。 我知道我们可以在呈现表单时设置自定义错误消息,但是我们可以在表单验证器中设置它吗?