本文整理汇总了PHP中Zend\Form\Element::setLabelAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::setLabelAttributes方法的具体用法?PHP Element::setLabelAttributes怎么用?PHP Element::setLabelAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element
的用法示例。
在下文中一共展示了Element::setLabelAttributes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanRenderRowLabelAttributes
public function testCanRenderRowLabelAttributes()
{
$element = new Element('foo');
$element->setLabel('The value for foo:');
$element->setLabelAttributes(array('class' => 'bar'));
$this->helper->setLabelPosition('append');
$markup = $this->helper->render($element);
$this->assertContains("<label class=\"bar\">", $markup);
}
示例2: renderLabel
/**
* Renders the control label for the Bootstrap control group
*
* @param Element $element
* @return string
*/
public function renderLabel(Element $element)
{
$label = '';
//Get the right class
$element->setLabelAttributes($this->setLabelClasses($element));
//Only add the class to the label if it is one of the control elements
if ($this->isControl($element) || $this->isRadio($element)) {
$label = $this->getView()->formLabel($element);
}
//Only control elements, multi-checkboxes, & radios have a label that appears outside of the control group
return $label;
}
示例3: __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;
}
示例4: __invoke
/**
* Outputs message depending on flag
*
* @return string
*/
public function __invoke(Element $element)
{
$element->setLabelAttributes(array('class' => 'control-label'));
$element->setAttribute('data-placement', 'bottom')->setAttribute('data-content', $element->getOption('description'));
if (!$element->getLabel()) {
$element->setLabel('öö');
}
$output = '<div class="control-group">';
$output .= $this->getView()->formLabel($element);
$output .= '<div class="controls">';
$output .= $this->getView()->formElement($element);
if ($element->getOption('description')) {
$output .= '<div class="description">' . $element->getOption('description') . '</div>';
}
if ($element->getMessages()) {
$output .= '<div class="alert alert-error">' . $this->getView()->formElementErrors($element) . '</div>';
}
$output .= '</div>';
$output .= '</div>';
return $output;
}
示例5: testsetLabelAttributes
public function testsetLabelAttributes()
{
$element = new Element('foo');
$element->setLabel('The value for foo:');
$element->setLabelAttributes(array('id' => 'bar'));
$markup = $this->helper->__invoke($element, '<input type="text" id="foo" />', FormLabelHelper::APPEND);
$this->assertContains('"foo" />The value for foo:</label>', $markup);
$this->assertContains('id="bar" for="foo"', $markup);
$this->assertContains('<label', $markup);
$this->assertContains('><input type="text" id="foo" />', $markup);
}
示例6: getElement
/**
* @param Zend\Form\Element $element
*
* @return string
*/
protected function getElement(Element $element)
{
$element->setLabelAttributes(array('class' => 'control-label col-sm-2'));
$element->setAttribute('data-placement', 'bottom')->setAttribute('class', 'form-control')->setAttribute('data-content', $element->getOption('description'))->setAttribute('data-trigger', 'focus');
if (!$element->getLabel()) {
$element->setLabel('öö');
}
$output = sprintf('<div class="form-group%1$s">', $element->getMEssages() && !$element instanceof \Zend\Form\Element\Collection ? ' has-error' : '');
$output .= $this->getView()->formLabel($element);
$output .= '<div class="col-sm-10">';
if ($element->getMessages() && !$element instanceof \Zend\Form\Element\Collection) {
$output .= sprintf('<div class="input-group"><span data-toggle="tooltip" data-placement="bottom" class="input-group-addon" data-html="true" title="%1$s"><i class="fa-warning fa"></i></span>', $this->getView()->formElementErrors($element));
}
if ($element instanceof \Zend\Form\Element\Collection) {
$output .= $this->getView()->formCollection($element);
} else {
$output .= $this->getView()->formElement($element);
}
if ($element->getMessages()) {
$output .= '</div>';
}
$output .= '</div>';
$output .= '</div>';
return $output;
}
示例7: 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' : '');
}