Esempio n. 1
0
 public function hasErrors()
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     if ($this->_formID == $request->getParam('form_name') || $this->_formID === null) {
         return parent::hasErrors();
     }
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
 /**
  * @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));
 }