我有一個表格檢查2個表格內數據庫中是否存在電子郵件。zend表格檢查記錄在數據庫中不存在
我使用Zend_Validate_Db_NoRecordExists來驗證,但它只檢查第二個。
任何想法爲什麼它不工作?
class Application_Form_ReferUser extends Zend_Form
{
public $email, $freeDownload, $buyNow;
public function init()
{
$this->setName('referUser');
$EmailExists = new Zend_Validate_Db_NoRecordExists(
array(
'table' => 'referrals',
'field' => 'email'
)
);
$EmailExists2 = new Zend_Validate_Db_NoRecordExists(
array(
'table' => 'users',
'field' => 'email'
)
);
$EmailExists->setMessage('This e-mail is already taken');
$EmailExists2->setMessage('This e-mail is already taken');
$this->email = $this->createElement('text', 'email')
->setLabel('Email')
->addValidator($EmailExists)
->addValidator($EmailExists2)
->addValidator('EmailAddress')
->setRequired(true);
$this->freeDownload = $this->createElement('button', 'btn_free_download')
->setLabel('Free Download')
->setAttrib('type', 'submit');
$this->buyNow = $this->createElement('button', 'btn_buy_now')
->setLabel('Buy Now')
->setAttrib('type', 'submit');
$this->addElements(array($this->email, $this->freeDownload, $this->buyNow));
$elementDecorators = array(
'ViewHelper'
);
$this->setElementDecorators($elementDecorators);
}
}
是的,我認爲這是真的,那覆蓋。所以,也許我要驗證它在控制器中。謝謝。 –