本文整理汇总了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);
}