本文整理汇总了PHP中Zend\Form\Element::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::getMessages方法的具体用法?PHP Element::getMessages怎么用?PHP Element::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element
的用法示例。
在下文中一共展示了Element::getMessages方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValidationClass
/**
* @param Element $element
* @param string $addToClass
*
* @return string
*/
public function getValidationClass(Element $element, $addToClass = '')
{
if (!$this->hasValidated) {
return $addToClass;
}
$addToClass = $addToClass ? $addToClass . ' ' : '';
if ($element->getMessages()) {
return $addToClass . 'has-error';
}
return $addToClass . 'has-success';
}
示例2: __invoke
public function __invoke(\Zend\Form\Element $e, $keyClasses = null)
{
$classes = $this->permanentClasses;
$messages = $e->getMessages();
if (!empty($messages)) {
if (!$keyClasses) {
$keyClasses = $this->defaultKeyClasses;
}
if (!isset($this->classes[$keyClasses])) {
throw new \RuntimeException(sprintf('A chave \'%s\' não existe no atributo $classes da Helper %s', $keyClasses, __CLASS__));
}
$classes .= ' ' . $this->classes[$keyClasses];
}
return $classes;
}
示例3: getHtml
/**
* __invoke
*
* @param Element $formElement
* @param $instanceConfig
*
* @return string
*/
public function getHtml(Element $formElement, $instanceConfig)
{
$labelName = $inputId = $formElement->getAttribute('name');
$fieldSetParts = explode('[', $labelName);
/**
* Handle elements that came from fieldSets
*/
if (count($fieldSetParts) > 1) {
$fieldSetParts = explode(']', $fieldSetParts[1]);
$labelName = $fieldSetParts[0] . $fieldSetParts[1];
$inputId = $fieldSetParts[0];
}
$instanceConfigLabelName = $labelName . 'Label';
$text = $instanceConfig[$instanceConfigLabelName];
return '<label for="' . $inputId . '"' . (count($formElement->getMessages()) ? ' class=invalid' : '') . ' data-textEdit="' . $instanceConfigLabelName . '">' . $text . '</label>';
}
示例4: __invoke
public function __invoke(Element $element)
{
$messages = $element->getMessages();
$out = '<div class="control-group';
if (count($messages)) {
$out .= ' error';
}
$out .= '">';
$element->setLabelAttributes(array('class' => 'control-label'));
$out .= $this->view->formLabel($element);
$out .= '<div class="controls">';
if ($element instanceof \Zend\Form\Element\Radio) {
$element->setLabelAttributes(array('class' => 'radio'));
}
$out .= $this->view->formElement($element);
$out .= $this->view->formElementErrors()->setMessageOpenFormat('<div class="help-inline">')->setMessageSeparatorString('. ')->setMessageCloseString('.</div>')->render($element);
$out .= '</div>';
$out .= '</div>';
return $out;
}
示例5: getMessages
/**
* @inheritdoc
*/
public function getMessages()
{
return $this->element->getMessages();
}
示例6: renderElement
public function renderElement(Element $element)
{
$element->setLabelAttributes(array('class' => 'sr-only'));
$element->setAttribute('class', 'form-control');
$labelHelper = $this->view->plugin('form_label');
$elementHelper = $this->getElementHelper();
$elementXhtml = '%1$s';
if ($element->getMessages() && !$element instanceof \Zend\Form\Element\Collection) {
$elementXhtml = '<div class="input-group"><span data-toggle="tooltip" data-placement="bottom" class="input-group-addon" data-html="true" title="%2$s"><i class="fa-warning fa"></i></span>%1$s</div>';
}
$output = '<div class="form-group%3$s">%1$s%2$s</div>';
return sprintf($output, $labelHelper($element), sprintf($elementXhtml, $elementHelper($element), $this->view->formElementErrors($element)), $element->getMessages() ? ' has-error' : '');
}