0
我有一個symfony 1.4驗證器的問題Symfony 1.4驗證器
我想寫我自己的驗證器,但我有一個小問題。
我的錯誤信息是一樣的,在形式的配置價值
我的代碼
class sfValidatorDefaultString extends sfValidatorString{
protected function configure($options = array(), $messages = array())
{
parent::configure($options, $messages);
$this->addMessage('default_string', 'Error message');
$this->addOption('default_string');
}
protected function doClean($value)
{
$clean = parent::doClean($value);
// tutaj utknąłem
if(in_array($value, $this->getOptions('default_string')))
{
throw new sfValidatorError($this, 'default_string', array('value' => $value['name'], 'default_string' => $this->getOption('default_string')));
}
return $clean;
}
}
我不明白你的問題..你能更明確嗎? – j0k 2012-04-17 10:14:01
'ContactForm 'name'=> new sfValidatorDefaultString(array(),array('default_string'=>'name')), ' '當用戶在input'name'名稱中寫入時,他會發生錯誤:''錯誤信息「,但現在他將有錯誤:'姓名' – Micchaleq 2012-04-17 10:22:16
另一個我怎樣才能使用$ this-> addMessage('default_string','**錯誤信息**'); in throw new sfValidatorError($ this,'** here **' – Micchaleq 2012-04-17 10:59:05