本文整理匯總了PHP中Zend_Form::addError方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Form::addError方法的具體用法?PHP Zend_Form::addError怎麽用?PHP Zend_Form::addError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Form
的用法示例。
在下文中一共展示了Zend_Form::addError方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validateForm
/**
* Faz a validação do formulário de usergroup (usado pelo Admin)
*
* @param Nidorx_Form $form
* @param Array $data
*/
public function validateForm(Zend_Form $form, $data)
{
if ($form->isValid($data)) {
$translator = new Nidorx_Translator();
$username = $form->getElement('username')->getValue();
if ($this->_daoUser->getByUsername($username)) {
$form->getElement('username')->addError($translator->translate('error_username_in_use'));
$form->addError($translator->translate('error_username_in_use'));
}
//Verificando se o email já está em uso
$email = $form->getElement('email')->getValue();
if ($this->_daoUser->getByEmail($email)) {
$form->getElement('email')->addError($translator->translate('error_email_in_use'));
$form->addError($translator->translate('error_email_in_use'));
}
};
return!$form->isErrors();
}
示例2: testIsValidShouldFailIfAddErrorHasBeenCalled
/**
* @group ZF-5150
*/
public function testIsValidShouldFailIfAddErrorHasBeenCalled()
{
$this->form->addError('Error');
$this->assertFalse($this->form->isValid(array()));
}
示例3: errorStackToForm
/**
* Set up an error handler proxying between Void_Doctrine_Record and Zend_Form.
* This method has to be executed after a validation has taken place.
*
* @param Void_Doctrine_Record $record A record we refer to
* @param string $column A column (field) name in this record
* @param Zend_Form $form A form we refer to
* @param string $field A name of form field
* @param array $mappings Key: an error type we expect to happen, value: an error message passed to form element when this error happens
*/
public function errorStackToForm($column, array $mappings, Zend_Form $form, $field = null) {
// Check if error stack for this record mentions column we refer to
if ($this->getErrorStack()->contains($column)) {
// Get errors for this column
foreach ($this->getErrorStack()->get($column) as $type) {
// Check if error type found exists in mappings, if so use it; if no, pass an error as-is
$error = (array_key_exists($type, $mappings) ? $mappings[$type] : $type);
if ($field === null) {
// Attach an error to the form
$form->addError($error);
} else {
// Attach an error to the form element given
$form->getElement($field)->addError($error);
}
}
}
}