当前位置: 首页>>代码示例>>PHP>>正文


PHP ElementInterface::isChecked方法代码示例

本文整理汇总了PHP中Zend\Form\ElementInterface::isChecked方法的典型用法代码示例。如果您正苦于以下问题:PHP ElementInterface::isChecked方法的具体用法?PHP ElementInterface::isChecked怎么用?PHP ElementInterface::isChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Form\ElementInterface的用法示例。


在下文中一共展示了ElementInterface::isChecked方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\InvalidArgumentException
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof CheckboxElement) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zend\\Form\\Element\\Checkbox', __METHOD__));
     }
     $name = $element->getName();
     if (empty($name) && $name !== 0) {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $attributes = $element->getAttributes();
     $attributes['name'] = $name;
     $attributes['type'] = $this->getInputType();
     $attributes['value'] = $element->getCheckedValue();
     $attributes['class'] = 'sr-only';
     $closingBracket = $this->getInlineClosingBracket();
     if ($element->isChecked()) {
         $attributes['checked'] = 'checked';
     }
     $input = sprintf('<input %s%s', $this->createAttributesString($attributes), $closingBracket);
     $label = $element->getLabel();
     $rendered = '<div class="checkbox"><label class="checkbox-custom" data-initialize="checkbox">' . $input . '<span class="checkbox-label">' . $label . '</span>' . '</label></div>';
     if ($element->useHiddenElement()) {
         $hiddenAttributes = array('name' => $attributes['name'], 'value' => $element->getUncheckedValue());
         $rendered = sprintf('<input type="hidden" %s%s', $this->createAttributesString($hiddenAttributes), $closingBracket) . $rendered;
     }
     return $rendered;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:35,代码来源:FormCheckBox.php

示例2: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param ElementInterface $element Zend Form Element
  *
  * @throws Exception\InvalidArgumentException
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof CheckboxElement) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zend\\Form\\Element\\Checkbox', __METHOD__));
     }
     $name = $element->getName();
     if (empty($name) && $name !== 0) {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $attributes = $element->getAttributes();
     $attributes['name'] = $name;
     $attributes['type'] = $this->getInputType();
     $attributes['value'] = $element->getCheckedValue();
     $closingBracket = $this->getInlineClosingBracket();
     if ($element->isChecked()) {
         $attributes['checked'] = 'checked';
     }
     if ($element->getAttribute('class') != 'input-checkbox') {
         $rendered = sprintf('<input %s%s', $this->createAttributesString($attributes), $closingBracket);
     } else {
         if ($element->getAttribute('id') == '') {
             $element->setAttribute('id', 'checkbox-' . uniqid());
         }
         unset($attributes['class']);
         $rendered = sprintf('<span class="input-checkbox"><input %s%s<label for="%s"></label></span>', $this->createAttributesString($attributes), $closingBracket, $element->getAttribute('id'));
     }
     return $rendered;
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:37,代码来源:FormCheckbox.php

示例3: render

 /**
  * @see \Zend\Form\View\Helper\FormCheckbox::render()
  * @param \Zend\Form\ElementInterface $oElement
  * @throws \LogicException
  * @throws \InvalidArgumentException
  * @return string
  */
 public function render(\Zend\Form\ElementInterface $oElement)
 {
     if (!$oElement instanceof \Zend\Form\Element\Checkbox) {
         throw new \InvalidArgumentException(sprintf('%s requires that the element is of type Zend\\Form\\Element\\Checkbox', __METHOD__));
     }
     if (($sName = $oElement->getName()) !== 0 && empty($sName)) {
         throw new \LogicException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $aAttributes = $oElement->getAttributes();
     $aAttributes['name'] = $sName;
     $aAttributes['type'] = $this->getInputType();
     $aAttributes['value'] = $oElement->getCheckedValue();
     $sClosingBracket = $this->getInlineClosingBracket();
     if ($oElement->isChecked()) {
         $aAttributes['checked'] = 'checked';
     }
     //Render label
     $sLabelOpen = $sLabelClose = $sLabelContent = '';
     //Render label and visible element
     if ($sLabelContent = $oElement->getLabel()) {
         if ($oTranslator = $this->getTranslator()) {
             $sLabelContent = $oTranslator->translate($sLabelContent, $this->getTranslatorTextDomain());
         }
         $oLabelHelper = $this->getLabelHelper();
         $sLabelOpen = $oLabelHelper->openTag($oElement->getLabelAttributes() ?: null);
         $sLabelClose = $oLabelHelper->closeTag();
     }
     //Render checkbox
     $sElementContent = sprintf('<input %s%s', $this->createAttributesString($aAttributes), $sClosingBracket);
     //Add label markup
     if ($this->getLabelPosition($oElement) === \Zend\Form\View\Helper\FormRow::LABEL_PREPEND) {
         $sElementContent = $sLabelOpen . ($sLabelContent ? rtrim($sLabelContent) . ' ' : '') . $sElementContent . $sLabelClose;
     } else {
         $sElementContent = $sLabelOpen . $sElementContent . ($sLabelContent ? ' ' . ltrim($sLabelContent) : '') . $sLabelClose;
     }
     //Render hidden input
     if ($oElement->useHiddenElement()) {
         $sElementContent = sprintf('<input type="hidden" %s%s', $this->createAttributesString(array('name' => $aAttributes['name'], 'value' => $oElement->getUncheckedValue())), $sClosingBracket) . $sElementContent;
     }
     return $sElementContent;
 }
开发者ID:eltonoliveira,项目名称:components_bootstrap,代码行数:48,代码来源:TwbBundleFormCheckbox.php

示例4: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws \Zend\Form\Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof CheckboxElement && !$element instanceof ZendCheckboxElement) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type ZfTwitterBootstrap\\Form\\Element\\Checkbox or Zend\\Form\\Element\\Checkbox', __METHOD__));
     }
     $name = $element->getName();
     if (empty($name) && $name !== 0) {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $attributes = $element->getAttributes();
     $attributes['name'] = $name;
     $attributes['type'] = $this->getInputType();
     $attributes['value'] = $element->getCheckedValue();
     $closingBracket = $this->getInlineClosingBracket();
     if ($element->isChecked()) {
         $attributes['checked'] = 'checked';
     }
     $rendered = sprintf('<input %s%s', $this->createAttributesString($attributes), $closingBracket);
     if ($element->useHiddenElement()) {
         $hiddenAttributes = array('name' => $attributes['name'], 'value' => $element->getUncheckedValue());
         $rendered = sprintf('<input type="hidden" %s%s', $this->createAttributesString($hiddenAttributes), $closingBracket) . $rendered;
     }
     return $rendered;
 }
开发者ID:rumeau,项目名称:zf-twitter-bootstrap,代码行数:31,代码来源:FormCheckbox.php

示例5: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\InvalidArgumentException
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof CheckboxElement) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type' . ' Zend\\Form\\Element\\Checkbox', __METHOD__));
     }
     $name = $element->getName();
     if (empty($name) && $name !== 0) {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name;' . ' none discovered', __METHOD__));
     }
     $attributes = $element->getAttributes();
     $attributes['name'] = $name;
     $attributes['type'] = $this->getInputType();
     $attributes['value'] = $element->getCheckedValue();
     $closingBracket = $this->getInlineClosingBracket();
     if ($element->isChecked()) {
         $attributes['checked'] = 'checked';
     }
     $input = sprintf('<input %s%s', $this->createAttributesString($attributes), $closingBracket);
     $escapeHtmlHelper = $this->getEscapeHtmlHelper();
     $labelHelper = $this->getLabelHelper();
     $labelClose = $labelHelper->closeTag();
     $labelPosition = $this->getLabelPosition();
     $globalLabelAttributes = $element->getLabelAttributes();
     if (empty($globalLabelAttributes)) {
         $globalLabelAttributes = $this->labelAttributes;
     }
     $label = $element->getAttribute('description') ?: $element->getLabel();
     $labelAttributes = $this->labelAttributes ?: $element->getLabelAttributes();
     if (null !== ($translator = $this->getTranslator())) {
         $label = $translator->translate($label, $this->getTranslatorTextDomain());
     }
     $label = $escapeHtmlHelper($label);
     $labelOpen = $labelHelper->openTag($labelAttributes);
     $template = $labelOpen . '%s%s' . $labelClose;
     switch ($labelPosition) {
         case static::LABEL_PREPEND:
             $rendered = sprintf($template, $label, $input);
             break;
         case static::LABEL_APPEND:
         default:
             $rendered = sprintf($template, $input, $label);
             break;
     }
     // Render hidden element
     $useHiddenElement = null !== $this->useHiddenElement ? $this->useHiddenElement : (method_exists($element, 'useHiddenElement') ? $element->useHiddenElement() : false);
     if ($useHiddenElement) {
         $hiddenAttributes = array('name' => $attributes['name'], 'value' => $element->getUncheckedValue());
         $rendered = sprintf('<input type="hidden" %s%s', $this->createAttributesString($hiddenAttributes), $closingBracket) . $rendered;
     }
     return $rendered;
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:59,代码来源:FormCheckbox.php


注:本文中的Zend\Form\ElementInterface::isChecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。