本文整理匯總了PHP中Zend_Form::hasErrors方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Form::hasErrors方法的具體用法?PHP Zend_Form::hasErrors怎麽用?PHP Zend_Form::hasErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Form
的用法示例。
在下文中一共展示了Zend_Form::hasErrors方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: hasErrors
public function hasErrors()
{
$request = Zend_Controller_Front::getInstance()->getRequest();
if ($this->_formID == $request->getParam('form_name') || $this->_formID === null) {
return parent::hasErrors();
}
}
示例2: testShouldAllowPushingErrorsOntoErrorStackWithErrorMessages
public function testShouldAllowPushingErrorsOntoErrorStackWithErrorMessages()
{
$this->assertFalse($this->form->hasErrors());
$this->form->setErrors(array('Error 1', 'Error 2'))->addError('Error 3')->addErrors(array('Error 4', 'Error 5'));
$this->assertTrue($this->form->hasErrors());
$messages = $this->form->getMessages();
$this->assertEquals(5, count($messages));
foreach (range(1, 5) as $id) {
$message = 'Error ' . $id;
$this->assertContains($message, $messages);
}
}
示例3: testHasErrorsMethodShouldCheckAlsoSubForms
/**
* @group GH-319
*/
public function testHasErrorsMethodShouldCheckAlsoSubForms()
{
// Init form
$form = new Zend_Form();
$subForm = new Zend_Form_SubForm();
$element = new Zend_Form_Element_Text('foo');
$subForm->addElement($element);
$form->addSubForm($subForm, 'subForm');
$element->markAsError();
// Test form
$this->assertTrue($form->hasErrors());
$this->assertFalse($form->isValid(array('foo' => 1)));
// Test element
$this->assertTrue($element->hasErrors());
$this->assertFalse($element->isValid(1));
}