本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例6: testSetMessagesWrongInputRaisesException
public function testSetMessagesWrongInputRaisesException()
{
$element = new Element('foo');
$this->setExpectedException('Zend\\Form\\Exception\\InvalidArgumentException');
$element->setMessages(null);
}
示例7: setMessages
/**
* @inheritdoc
*/
public function setMessages($messages)
{
return $this->element->setMessages($messages);
}
示例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);
}