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


PHP ElementInterface::getName方法代码示例

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


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

示例1: remove

 /**
  * {@inheritDoc}
  */
 public function remove($elementOrFieldset)
 {
     if (!parent::has($elementOrFieldset) && $elementOrFieldset === 'identity' && $this->identityElement) {
         $elementOrFieldset = $this->identityElement->getName();
     }
     return parent::remove($elementOrFieldset);
 }
开发者ID:coolms,项目名称:user,代码行数:10,代码来源:ResetPassword.php

示例2: getRules

 /**
  * {@inheritDoc}
  */
 public function getRules(ValidatorInterface $validator, ElementInterface $element = null)
 {
     $token = $validator->getToken();
     if (strpos($element->getName(), "[") !== false) {
         $token = preg_replace('#\\[[^\\]]+\\]$#i', "[" . $token . "]", $element->getName());
     }
     return array('equalTo' => '[name="' . $token . '"]');
 }
开发者ID:rettal,项目名称:zf2-form,代码行数:11,代码来源:Identical.php

示例3: remove

 /**
  * {@inheritDoc}
  */
 public function remove($elementOrFieldset)
 {
     if (!parent::has($elementOrFieldset)) {
         if ($elementOrFieldset === 'identity' && $this->identityElement) {
             $elementOrFieldset = $this->identityElement->getName();
         } elseif ($elementOrFieldset === 'credential' && $this->credentialElement) {
             $elementOrFieldset = $this->credentialElement->getName();
         }
     }
     return parent::remove($elementOrFieldset);
 }
开发者ID:coolms,项目名称:authentication,代码行数:14,代码来源:Login.php

示例4: 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

示例5: 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

示例6: render

 /**
  * Render a form radio-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 RadioGroup) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zork\\Form\\Element\\RadioGroup', __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();
     $additionalAttribures = array('type' => 'radio', 'name' => $name, 'required' => empty($attributes['required']) ? null : 'required');
     $this->validTagAttributes = $this->validRadioGroupAttributes;
     return sprintf('<div %s>%s</div>', $this->createAttributesString($attributes), $this->renderRadios($options, $value, $additionalAttribures, $element->getOption('option_attribute_filters')));
 }
开发者ID:gridguyz,项目名称:zork,代码行数:34,代码来源:FormRadioGroup.php

示例7: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $name = $element->getName();
     if ($name === null || $name === '') {
         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->getType($element);
     $attributes['value'] = $element->getValue();
     //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('url', '/skrar/mynd')->setOption('accept', 'image/*')->setOption('mime', '/image\\/jpg|jpeg|png|gif/');
     //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-img %s><input %s%s</stjornvisi-img>', implode(' ', $strings), $this->createAttributesString($attributes), $this->getInlineClosingBracket());
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:37,代码来源:ImgElement.php

示例8: 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

示例9: 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

示例10: __invoke

 public function __invoke(ElementInterface $element)
 {
     $elementHelper = $this->getElementHelper();
     $name = preg_replace('/[^a-z0-9_-]+/', '', $element->getName());
     $result = '<div id="custom' . $name . '">' . $elementHelper($element) . '</div>';
     return $result;
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:7,代码来源:CustomViewHelper.php

示例11: 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

示例12: 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

示例13: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $name = $element->getName();
     if ($name === null || $name === '') {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $attributes = $element->getAttributes();
     $attributes['type'] = $this->getType($element);
     $attributes['name'] = $name;
     if (array_key_exists('multiple', $attributes) && $attributes['multiple']) {
         $attributes['name'] .= '[]';
     }
     $value = $element->getValue();
     if (is_array($value) && isset($value['name']) && !is_array($value['name'])) {
         $attributes['value'] = $value['name'];
     } elseif (is_string($value)) {
         $attributes['value'] = $value;
     }
     $size = $element->getOption('size');
     if (empty($size)) {
         return sprintf('<input %s%s', $this->createAttributesString($attributes), $this->getInlineClosingBracket());
     }
     return sprintf('<div class="col-lg-%s col-md-%s col-sm-%s col-xs-%s">
             <input %s%s
         </div>', $size, $size, $size, $size, $this->createAttributesString($attributes), $this->getInlineClosingBracket());
 }
开发者ID:skpd,项目名称:bootstrap,代码行数:33,代码来源:FormFile.php

示例14: 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

示例15: openTag

 /**
  * Returns the control group open tag
  * @param ElementInterface $element
  * @return string
  */
 public function openTag(ElementInterface $element)
 {
     $class = 'controls';
     $id = 'controls-' . $element->getName();
     $html = sprintf('<div class="%s" id="%s">', $class, $id);
     return $html;
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:12,代码来源:FormControlsTwb.php


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