當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Element::setMessages方法代碼示例

本文整理匯總了PHP中Zend\Form\Element::setMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Element::setMessages方法的具體用法?PHP Element::setMessages怎麽用?PHP Element::setMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Form\Element的用法示例。


在下文中一共展示了Element::setMessages方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testRendersNestedMessageSetsAsAFlatList

 public function testRendersNestedMessageSetsAsAFlatList()
 {
     $messages = array(array('First validator message'), array('Second validator first message', 'Second validator second message'));
     $element = new Element('foo');
     $element->setMessages($messages);
     $markup = $this->helper->render($element, array('class' => 'error'));
     $this->assertRegexp('#<ul class="error">\\s*<li>First validator message</li>\\s*<li>Second validator first message</li>\\s*<li>Second validator second message</li>\\s*</ul>#s', $markup);
 }
開發者ID:haoyanfei,項目名稱:zf2,代碼行數:8,代碼來源:FormElementErrorsTest.php

示例2: testRendersOnErrorAsEspected

 public function testRendersOnErrorAsEspected()
 {
     $element = new Element('testElement');
     $element->setAttribute('value', 'Initial Content');
     $element->setMessages(array('testElement' => 'no valid'));
     $markup = $this->helper->render($element);
     $this->assertContains('error', $markup);
 }
開發者ID:3makkk,項目名稱:Foundation,代碼行數:8,代碼來源:FormElementTest.php

示例3: testRendersErrorMessagesUsingSpans

 public function testRendersErrorMessagesUsingSpans()
 {
     $messages = $this->getMessageList();
     $element = new Element('foo');
     $element->setMessages($messages);
     $markup = $this->helper->render($element);
     $this->assertRegexp('#<span class="help-inline">First error message</span>\\s*<span class="help-inline">Second error message</span>#s', $markup);
 }
開發者ID:rhysr,項目名稱:zf2twitterbootstrap,代碼行數:8,代碼來源:FormElementErrorsInlineTest.php

示例4: testPassingElementWithErrorsAddsErrorClass

 public function testPassingElementWithErrorsAddsErrorClass()
 {
     $element = new Element('test');
     $element->setMessages(array('FAIL'));
     $markup = $this->helper->openTag($element);
     $this->assertEquals(1, preg_match('/class="(.*)"/', $markup, $matches));
     $classes = explode(' ', $matches[1]);
     $this->assertContains('error', $classes);
     $this->assertContains('control-group', $classes);
 }
開發者ID:rhysr,項目名稱:zf2twitterbootstrap,代碼行數:10,代碼來源:ControlGroupTest.php

示例5: testDoesNotOverrideClassesIfAlreadyPresentWhenThereAreErrors

 public function testDoesNotOverrideClassesIfAlreadyPresentWhenThereAreErrors()
 {
     $element = new Element('foo');
     $element->setMessages(array('Error message'));
     $element->setAttribute('class', 'foo bar');
     $markup = $this->helper->setInputErrorClass('custom-error-class')->render($element);
     $this->assertRegexp('/<input name="foo" class="foo bar custom-error-class" type="text" [^\\/>]*\\/?>/', $markup);
 }
開發者ID:razvansividra,項目名稱:pnlzf2-1,代碼行數:8,代碼來源:FormRowTest.php

示例6: testSetMessagesWrongInputRaisesException

 public function testSetMessagesWrongInputRaisesException()
 {
     $element = new Element('foo');
     $this->setExpectedException('Zend\\Form\\Exception\\InvalidArgumentException');
     $element->setMessages(null);
 }
開發者ID:razvansividra,項目名稱:pnlzf2-1,代碼行數:6,代碼來源:ElementTest.php

示例7: setMessages

 /**
  * @inheritdoc
  */
 public function setMessages($messages)
 {
     return $this->element->setMessages($messages);
 }
開發者ID:adacap,項目名稱:3agest-prototype,代碼行數:7,代碼來源:Element.php

示例8: testCanRenderErrors

 public function testCanRenderErrors()
 {
     $element = new Element('foo');
     $element->setMessages(array('First error message', 'Second error message', 'Third error message'));
     $markup = $this->helper->render($element);
     $this->assertRegexp('#<ul>\\s*<li>First error message</li>\\s*<li>Second error message</li>\\s*<li>Third error message</li>\\s*</ul>#s', $markup);
 }
開發者ID:robertodormepoco,項目名稱:zf2,代碼行數:7,代碼來源:FormRowTest.php


注:本文中的Zend\Form\Element::setMessages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。