0
我在symfony 1.4中創建了一個丟失的密碼錶單,並且遇到了即使小部件約束失敗也會調用post驗證器的問題。Symfony 1.4 - 強制symfony在到達驗證器之前停止執行
段:
$this->validatorSchema['email_address'] = new sfValidatorEmail(
array(
'max_length' => 254, // http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690
'min_length' => 4,
'required' => true,
'trim' => true
),
array(
'invalid' => 'Email address entered is malformed',
'max_length' => 'Email Address cannot contain more than %max_length% characters',
'min_length' => 'Email Address must be at least %min_length% characters',
'required' => 'Please enter an email address'
)
);
$this->mergePostValidator(new sfValidatorCallback(array('callback' => array($this, 'emailValidate'))));
$this->mergePostValidator(new sfValidatorCallback(array('callback' => array($this, 'throttleCheck'))));
的問題是「emailValidate」回調呈現出良好形成的電子郵件地址已輸入,像[email protected],但如果我進入垃圾,像「fdadfaa」,當它不應該的時候,表單仍然繼續嘗試執行驗證器。如果數據不好,沒有理由發出查詢。
我一個'halt_on_error'標誌可以傳遞給模式驗證器的構造函數,但並不適用於我。其他人穿過這座橋?