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


PHP ElementInterface::getValue方法代码示例

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


在下文中一共展示了ElementInterface::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
 {
     $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'] = 'text';
     $attributes['class'] = 'form-control';
     $attributes['value'] = $element->getValue();
     $attributes['date'] = $element->getValue();
     $attributes['readonly'] = 'readonly';
     $closingBracket = $this->getInlineClosingBracket();
     $jsAttributes = array();
     if (isset($attributes['allowPastDates'])) {
         $jsAttributes['allowPastDates'] = $attributes['allowPastDates'];
         unset($attributes['allowPastDates']);
     }
     if (isset($attributes['date'])) {
         $jsAttributes['date'] = $attributes['date'];
         unset($attributes['date']);
     }
     if (isset($attributes['formatDate'])) {
         $jsAttributes['formatDate'] = $attributes['formatDate'];
         unset($attributes['formatDate']);
     }
     if (isset($attributes['momentConfig'])) {
         $jsAttributes['momentConfig'] = $attributes['momentConfig'];
         unset($attributes['momentConfig']);
     }
     if (isset($attributes['sameYearOnly'])) {
         $jsAttributes['sameYearOnly'] = $attributes['sameYearOnly'];
         unset($attributes['sameYearOnly']);
     }
     $script = $this->scriptAttributes($name, $jsAttributes);
     $input = sprintf('<input %s%s', $this->createAttributesString($attributes), $closingBracket);
     $wrapper = '<div class="dropdown-menu dropdown-menu-right datepicker-calendar-wrapper" role="menu">';
     $wrapper .= $this->calendar();
     $wrapper .= $this->monthWheel();
     $wrapper .= '</div>';
     $datePicker = '<div class="input-group">';
     $datePicker .= $input;
     $datePicker .= '<div class="input-group-btn">';
     $datePicker .= '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">';
     $datePicker .= '<span class="glyphicon glyphicon-calendar"></span>';
     $datePicker .= '<span class="sr-only">Toggle Calendar</span>';
     $datePicker .= '</button>';
     $datePicker .= $wrapper;
     $datePicker .= '</div>';
     $datePicker .= '</div>';
     $rendered = $script . '<div class="datepicker" id="' . $name . '">' . $datePicker . '</div>';
     return $rendered;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:62,代码来源:FormDate.php

示例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)
 {
     //$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;
 }
开发者ID:vfulco,项目名称:YAWIK,代码行数:34,代码来源:ToggleButton.php

示例3: render

 /**
  * Render a form checkbox-group element from the provided $element
  *
  * @param   \Zend\Form\ElementInterface $element
  * @throws  \Zend\Form\Exception\InvalidArgumentException
  * @throws  \Zend\Form\Exception\DomainException
  * @return  string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof TagBanners) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Grid\\Banner\\Form\\Element\\TagBanners', __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__));
     }
     $appService = $this->getAppServiceHelper();
     $tagModel = $appService('Grid\\Tag\\Model\\Tag\\Model');
     $attributes = $element->getAttributes();
     $value = (array) $element->getValue();
     $groups = array();
     foreach ($value as $tagId => $banners) {
         $tag = $tagModel->find($tagId);
         if ($tag && $tag->locale) {
             $locale = 'locale.sub.' . $tag->locale;
             if ($this->isTranslatorEnabled() && $this->hasTranslator()) {
                 $locale = $this->getTranslator()->translate($locale, 'locale');
             }
         }
         $label = $tag ? $tag->name . (isset($locale) ? ' (' . $locale . ')' : '') : '#' . $tagId;
         $groups[] = array('header' => $label, 'markup' => $this->renderBanners($name . '[' . $tagId . ']', $banners), 'attributes' => array('data-tagid' => $tagId));
     }
     unset($attributes['name']);
     return $this->renderBannerGroups($name . '[__tagid__]', $attributes, $groups);
 }
开发者ID:gridguyz,项目名称:banner,代码行数:36,代码来源:FormBannerTags.php

示例4: render

 public function render(ElementInterface $element)
 {
     $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;
     $content = (string) $element->getValue();
     $escapeHtml = $this->getEscapeHtmlHelper();
     //ADD OPTIONS
     //	this should really be in Stjonvisi\Form\Element\Img
     //	but it gets overwritten at some point, so the simplest
     //	thing was to add it here.
     //	TODO place this i a more generic place
     $element->setOption('max', $this->getMaxSize())->setOption('mime', '/image\\/jpg|png|gif/')->setOption('url', '/skrar/mynd');
     //OPTIONS
     //	options are used to set attributes and values
     //	to the custom element. We therefore need to remove
     //	label, label_attributes and label_options before we
     //	can convert them into an attribute string.
     $options = $element->getOptions();
     unset($options['label']);
     unset($options['label_attributes']);
     unset($options['label_options']);
     $strings = array_map(function ($key, $value) {
         return sprintf('%s="%s"', $key, $value);
     }, array_keys($options), $options);
     return sprintf('<stjornvisi-rich %s><textarea %s>%s</textarea></stjornvisi-rich>', implode(' ', $strings), $this->createAttributesString($attributes), $escapeHtml($content));
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:30,代码来源:RichElement.php

示例5: render

 /**
  * Render a form <select> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\InvalidArgumentException
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof SelectElement) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zend\\Form\\Element\\Select', __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__));
     }
     $options = $element->getValueOptions();
     if (($emptyOption = $element->getEmptyOption()) !== null) {
         $options = array('' => $emptyOption) + $options;
     }
     $attributes = $element->getAttributes();
     $value = $this->validateMultiValue($element->getValue(), $attributes);
     $attributes['name'] = $name;
     if (array_key_exists('multiple', $attributes) && $attributes['multiple']) {
         $attributes['name'] .= '[]';
     }
     $this->validTagAttributes = $this->validSelectAttributes;
     $size = $element->getOption('size');
     if (empty($size)) {
         return sprintf('<select %s>%s</select>', $this->createAttributesString($attributes), $this->renderOptions($options, $value));
     }
     return sprintf('<div class="col-lg-%s col-md-%s col-sm-%s col-xs-%s">
             <select %s>%s</select>
         </div>', $size, $size, $size, $size, $this->createAttributesString($attributes), $this->renderOptions($options, $value));
 }
开发者ID:skpd,项目名称:bootstrap,代码行数:36,代码来源:FormSelect.php

示例6: render

 /**
  * Render a form checkbox-group element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\InvalidArgumentException
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof MultiCheckboxGroup) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zork\\Form\\Element\\MutiCheckboxGroup', __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__));
     }
     $options = $element->getValueOptions();
     if (empty($options)) {
         if (($translator = $this->getTranslator()) !== null) {
             return '<i>' . $translator->translate('default.empty', 'default') . '</i>';
         } else {
             return '';
         }
     }
     if (($emptyOption = $element->getEmptyOption()) !== null) {
         $options = array('' => $emptyOption) + $options;
     }
     $attributes = $element->getAttributes();
     $value = $element->getValue();
     $addAttr = array('type' => 'checkbox', 'name' => substr($name, -2) == '[]' ? $name : $name . '[]', 'required' => empty($attributes['required']) ? null : 'required');
     $this->validTagAttributes = $this->validCheckboxGroupAttributes;
     if (null !== $element->getTranslatorTextDomain()) {
         $this->setTranslatorTextDomain($element->getTranslatorTextDomain());
     }
     if (empty($attributes['class'])) {
         $attributes['class'] = 'multi_checkbox';
     }
     return sprintf('<div %s>%s</div>', $this->createAttributesString($attributes), sprintf('<input type="hidden" name="%s" value="" />' . PHP_EOL, substr($name, -2) == '[]' ? substr($name, 0, -2) : $name) . $this->renderCheckboxes($options, $value, $addAttr));
 }
开发者ID:gridguyz,项目名称:zork,代码行数:40,代码来源:FormMultiCheckboxGroup.php

示例7: 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) {
         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__));
     }
     $checkedValue = $element->getCheckedValue();
     $uncheckedValue = $element->getUncheckedValue();
     $useHiddenElement = $element->useHiddenElement();
     $attributes = $element->getAttributes();
     $attributes['name'] = $name;
     $attributes['checked'] = '';
     $attributes['type'] = $this->getInputType();
     $closingBracket = $this->getInlineClosingBracket();
     $value = $element->getValue();
     if ($value === $checkedValue) {
         $attributes['checked'] = 'checked';
     }
     $attributes['value'] = $checkedValue;
     $rendered = sprintf('<input %s%s', $this->createAttributesString($attributes), $closingBracket);
     if ($useHiddenElement) {
         $hiddenAttributes = array('name' => $attributes['name'], 'value' => $uncheckedValue);
         $rendered = sprintf('<input type="hidden" %s%s', $this->createAttributesString($hiddenAttributes), $closingBracket) . $rendered;
     }
     return $rendered;
 }
开发者ID:Rovak,项目名称:zf2,代码行数:36,代码来源:FormCheckbox.php

示例8: render

 public function render(ElementInterface $element)
 {
     if (in_array($element->getAttribute('type'), array('html'))) {
         return $element->getValue();
     }
     return parent::render($element);
 }
开发者ID:ualisonaguiar,项目名称:shome2,代码行数:7,代码来源:FormRow.php

示例9: render

 /**
  * Render a form <select> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws \Zend\Form\Exception\InvalidArgumentException
  * @throws \Zend\Form\Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof Reference) {
         throw new \Zend\Form\Exception\InvalidArgumentException(sprintf('%s requires that the element is of type MfccAdminModule\\Form\\Element\\Reference', __METHOD__));
     }
     $name = $element->getName();
     if (empty($name) && $name !== 0) {
         throw new \Zend\Form\Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $options = $element->getValueOptions();
     if (($emptyOption = $element->getEmptyOption()) !== null) {
         $options = ['' => $emptyOption] + $options;
     }
     $attributes = $element->getAttributes();
     $value = $this->validateMultiValue($element->getValue(), $attributes);
     $attributes['name'] = $name;
     if (array_key_exists('multiple', $attributes) && $attributes['multiple']) {
         $attributes['name'] .= '[]';
     }
     $this->validTagAttributes = $this->validSelectAttributes;
     $rendered = sprintf('<select %s>%s</select>', $this->createAttributesString($attributes), $this->renderOptions($options, $value));
     // Render hidden element
     $useHiddenElement = method_exists($element, 'useHiddenElement') && method_exists($element, 'getUnselectedValue') && $element->useHiddenElement();
     if ($useHiddenElement) {
         $rendered = $this->renderHiddenElement($element) . $rendered;
     }
     return $rendered;
 }
开发者ID:bedi,项目名称:mfcc-admin-module,代码行数:36,代码来源:FormReference.php

示例10: initFormElement

 /**
  * {@InheritDoc}
  */
 protected function initFormElement(ElementInterface $element)
 {
     $value = $element->getValue();
     if (!empty($value)) {
         $this->value($value);
     }
     return parent::initFormElement($element);
 }
开发者ID:spoonx,项目名称:sxbootstrap,代码行数:11,代码来源:Submit.php

示例11: initFormElement

 /**
  * {@InheritDoc}
  */
 protected function initFormElement(ElementInterface $element)
 {
     $value = $element->getValue();
     if (!empty($value)) {
         $this->addAttribute('value', $this->translate($value));
     }
     return parent::initFormElement($element);
 }
开发者ID:spoonx,项目名称:sxbootstrap,代码行数:11,代码来源:Button.php

示例12: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof Date) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zend\\Form\\Element\\Date', __METHOD__));
     }
     return '<div class="input-group date datetimepicker"  data-date-format="YYYY-MM-DD">
                 <input name="' . $element->getName() . '" type="text" class="form-control" value="' . $element->getValue() . '" />
                 <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
             </div>';
 }
开发者ID:Patinger,项目名称:Browsergame,代码行数:16,代码来源:Datepicker.php

示例13: getHiddenElement

 public function getHiddenElement(ElementInterface $element)
 {
     if ($element instanceof Hidden) {
         return $element;
     }
     $name = $element->getName();
     $value = $element->getValue();
     $hidden = new Hidden($name);
     $hidden->setValue($value);
     return $hidden;
 }
开发者ID:phower,项目名称:zf2-bootstrap3-module,代码行数:11,代码来源:FormElementStatic.php

示例14: initFormElement

 /**
  * @param ElementInterface $element
  *
  * @return \SxBootstrap\View\Helper\Bootstrap\Form\Input
  */
 protected function initFormElement(ElementInterface $element)
 {
     $this->name($element->getName())->type('text');
     $this->getElement()->addAttributes($element->getAttributes());
     $type = $element->getAttribute('type');
     if (null !== $type) {
         $this->type(strtolower($type));
     }
     $this->value($element->getValue());
     return $this;
 }
开发者ID:spoonx,项目名称:sxbootstrap,代码行数:16,代码来源:Input.php

示例15: render

 /**
  * Render a form <textarea> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $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;
     $content = (string) $element->getValue();
     $escapeHtml = $this->getEscapeHtmlHelper();
     return sprintf('<textarea %s>%s</textarea>', $this->createAttributesString($attributes), $escapeHtml($content));
 }
开发者ID:leonardovn86,项目名称:zf2_basic2013,代码行数:19,代码来源:FormTextarea.php


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