本文整理匯總了PHP中Zend\Form\ElementInterface::setLabel方法的典型用法代碼示例。如果您正苦於以下問題:PHP ElementInterface::setLabel方法的具體用法?PHP ElementInterface::setLabel怎麽用?PHP ElementInterface::setLabel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Form\ElementInterface
的用法示例。
在下文中一共展示了ElementInterface::setLabel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
/**
* Render a form <input> element from the provided $element
*
* @param ElementInterface $element
* @param String $buttonContent
* @throws Exception\DomainException
* @return string
*/
public function render(ElementInterface $element, $buttonContent = null)
{
//$view = $this->getView();
//$view->headScript()->appendFile($view->basePath('/Core/js/bootstrap-switch.js'));
if (null === $buttonContent) {
$buttonContent = $element->getLabel();
if (null === $buttonContent) {
throw new Exception\DomainException(sprintf('%s expects either button content as the second argument, ' . 'or that the element provided has a label value; neither found', __METHOD__));
}
if (null !== ($translator = $this->getTranslator())) {
$buttonContent = $translator->translate($buttonContent, $this->getTranslatorTextDomain());
}
$element->setLabel('');
}
//$escape = $this->getEscapeHtmlHelper();
//$translator = $this->getTranslator();
//$name = $element->getName();
$value = $element->getValue();
$checkedBoole = $value == 1 || $value == 'on';
//$checked = $checkedBoole?'checked="checked"':'';
$checkedClass = $checkedBoole ? 'active"' : '';
$buttonContent = '<div class="btn-group" data-toggle="buttons">' . PHP_EOL . '<span class="btn btn-default ' . $checkedClass . '">' . PHP_EOL . parent::render($element) . $buttonContent . PHP_EOL . '</span>' . PHP_EOL . '</div>' . PHP_EOL;
//$buttonContent = '<div><div class="processing yk-hidden"><span class="fa-spin yk-icon-spinner yk-icon"></span> ' .
// $translator->translate('processing', $this->getTranslatorTextDomain()) . '</div><div class="default">' . $escape($buttonContent) . '</div></div>';
return $buttonContent;
}
示例2: render
/**
* Render a form <input> element from the provided $element
*
* @param ElementInterface $element
* @param String $buttonContent
* @throws Exception\DomainException
* @return string
*/
public function render(ElementInterface $element, $buttonContent = null)
{
if (null === $buttonContent) {
$buttonContent = $element->getLabel();
if (null === $buttonContent) {
throw new Exception\DomainException(sprintf('%s expects either button content as the second argument, ' . 'or that the element provided has a label value; neither found', __METHOD__));
}
if (null !== ($translator = $this->getTranslator())) {
$buttonContent = $translator->translate($buttonContent, $this->getTranslatorTextDomain());
}
$element->setLabel('');
}
$value = $element->getValue();
$checkedBoole = $value == 1 || $value == 'on';
$checkedClass = $checkedBoole ? 'active"' : '';
$hiddenElement = '';
if ($element->useHiddenElement()) {
$hiddenAttributes = ['name' => $element->getName(), 'value' => $element->getUncheckedValue()];
$hiddenElement = sprintf('<input type="hidden" %s%s', $this->createAttributesString($hiddenAttributes), '>');
$element->setUseHiddenElement(false);
}
$buttonContent = $hiddenElement . PHP_EOL . '<div class="btn-group" data-toggle="buttons">' . PHP_EOL . '<label class="btn btn-default ' . $checkedClass . '">' . PHP_EOL . parent::render($element) . $buttonContent . PHP_EOL . '</label>' . PHP_EOL . '</div>' . PHP_EOL;
return $buttonContent;
}