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


PHP Zend_Form_Element::getAttrib方法代码示例

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


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

示例1: aElement

 /**
  * Render element
  *
  * @param Zend_Form_Element $element
  * @return string
  */
 public function aElement(Zend_Form_Element $element)
 {
     $viewClasses = array($element->getAttrib('class'));
     if ($element->isRequired()) {
         if (!$element->getAttrib('title')) {
             $element->setAttrib('title', 'Field is required');
         }
         $viewClasses[] = 'aForm-field-required';
     }
     if ($element->getValidators()) {
         $viewClasses[] = 'aForm-field-validate';
     }
     if ($element->hasErrors()) {
         $viewClasses[] = 'aForm-field-invalid';
     } elseif ($element->getValue() || !$element->isRequired()) {
         $viewClasses[] = 'aForm-field-valid';
     }
     if ($element->getValidators()) {
         $viewClasses[] = 'aForm-field-validate';
     }
     $element->setAttrib('class', implode(' ', $viewClasses));
     $options = null;
     $separator = null;
     if ($element instanceof Zend_Form_Element_Multi) {
         $options = $element->getMultiOptions();
         $separator = $element->getSeparator();
     }
     return $this->view->{$element->helper}($element->getName(), $element->getValue(), $element->getAttribs(), $options, $separator);
 }
开发者ID:uglide,项目名称:zfcore-transition,代码行数:35,代码来源:AElement.php

示例2: buildInput

 /**
  * Construit un champ de type input (générique) avec le helper de Zend correspondant a ce champ
  *
  * @brief	construit un champ générique
  * @author	francoisespinet
  * 	@param Zend_Form_Element $oElement
  */
 protected function buildInput(Zend_Form_Element $oElement, $bNoErreurs = false)
 {
     //ajout des erreurs si besoin
     if ($oElement->getAttrib(self::FORM_HAS_ERROR) && !$bNoErreurs) {
         return $this->formAddErreurChamp($oElement->renderViewHelper(), $oElement->hasErrors());
     } else {
         return $oElement->renderViewHelper();
     }
 }
开发者ID:netixx,项目名称:Stock,代码行数:16,代码来源:Abstract.php

示例3: renderFormElement

 /**
  * Enter description here ...
  * @param Zend_Form_Element $element
  * @author Tung Ly
  */
 public function renderFormElement($element, $vertical = 0)
 {
     if ($element->getType() != "Zend_Form_Element_Checkbox") {
         $element->setAttrib('class', $element->getAttrib('class') . ' form-control');
     }
     if ($element->isRequired()) {
         $element->setLabel($element->getLabel() . ' *');
         $element->setAttrib('class', $element->getAttrib('class') . ' required');
     }
     switch ($element->getType()) {
         case 'Zend_Form_Element_Textarea':
             $element->setAttrib('rows', 5);
             $element->setAttrib('cols', 80);
             break;
         case 'Zend_Form_Element_Hidden':
             return $element;
         default:
             break;
     }
     $error = '';
     if ($element->hasErrors()) {
         $error = 'has-error';
     }
     if ($element->getType() == 'Zend_Form_Element_Textarea') {
     }
     $btn = array('Zend_Form_Element_Submit', 'Zend_Form_Element_Reset');
     if (in_array($element->getType(), $btn)) {
         //$t ='<button type="reset" class="btn"><i class="icon-refresh"></i> '.$element->getLabel().'</button>';
         $t = '<div class="span2">' . $element . '</div>';
     } else {
         $label = trim(preg_replace("/([A-Z])/", " \$1", "{$element->getLabel()}"), ' ');
         $variables = array('%%ERROR_CLASS%%' => $error, '%%ELEMENT_NAME%%' => $element->getName(), '%%ELEMENT_LABEL%%' => $label, '%%ELEMENT%%' => $element, '%%HELP_MESSAGE%%' => current($element->getMessages()));
         $t = str_replace(array_keys($variables), $variables, $this->_getTemplate($vertical));
     }
     return $t;
 }
开发者ID:hocondoimeo,项目名称:giasu-tam.com,代码行数:41,代码来源:RenderFormElement.php

示例4: _getClassNames

 /**
  * Extract the class names from a Zend_Form_Element if given or from the
  * base form
  *
  * @param  Zend_Form_Element $element
  * @return array
  */
 protected function _getClassNames(Zend_Form_Element $element = null)
 {
     if (null !== $element) {
         return explode(' ', $element->getAttrib('class'));
     }
     return explode(' ', $this->getAttrib('class'));
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:14,代码来源:Form.php

示例5: setElementDecorator

 /**
  * Static function that adds all the elements in 1 wrapping element instead of dt, dd structure
  *
  * @param $elm
  * @return void
  */
 public static function setElementDecorator(Zend_Form_Element $elm)
 {
     $elm->addPrefixPath('Glitch_Form_Decorator', 'Glitch/Form/Decorator/', 'decorator');
     $labelSettings = array();
     if ($elm->getDecorator('Label')) {
         $labelSettings = $elm->getDecorator('Label')->getOptions();
         unset($labelSettings['tag']);
         //Tag should never be needed when you call this method
     }
     $class = 'wrapper';
     if ($elm->getAttrib('wrapperClass')) {
         $class .= ' ' . $elm->getAttrib('wrapperClass');
         $elm->setAttrib('wrapperClass', null);
     }
     if ($elm instanceof Zend_Form_Element_Hidden) {
         $class .= ' hidden';
     }
     $elm->clearDecorators()->addDecorator('Label', $labelSettings)->addDecorator('ViewHelper')->addDecorator('Description', array('escape' => false))->addDecorator('Errors')->addDecorator('Wrapper', array('tag' => 'div', 'id' => $elm->getName() . '-wrapper', 'class' => $class));
     if ($elm instanceof Zend_Form_Element_Submit) {
         $elm->removeDecorator('Label');
     }
 }
开发者ID:nstapelbroek,项目名称:Glitch_Lib,代码行数:28,代码来源:Form.php

示例6: cleanElement

 /**
  * Clean decorators for an element.
  *
  * @param Zend_Form_Element $element
  * @return $this
  */
 public function cleanElement(Zend_Form_Element $element)
 {
     if (!$element instanceof Zend_Form_Element_File && !$element instanceof Zend_Form_Element_Captcha) {
         $decorators = $this->defaultNoElementDecorator;
         if (!$element instanceof Zend_Form_Element_Hidden) {
             $decorators = $this->defaultElementDecorators;
         }
         if ($element instanceof Zend_Form_Element_Checkbox) {
             $element->setAttrib('class', $element->getAttrib('class') . ' field-checkbox');
         }
         if ($element instanceof Zend_Form_Element_MultiCheckbox) {
             $element->setAttrib('class', $element->getAttrib('class') . ' field-checkbox');
         }
         if ($element instanceof Zend_Form_Element_Radio) {
             $element->setAttrib('class', $element->getAttrib('class') . ' field-radio');
         }
         if ($element instanceof Zend_Form_Element_Text || $element instanceof Zend_Form_Element_Password) {
             $element->setAttrib('class', $element->getAttrib('class') . ' field-text');
         }
         if ($element instanceof Zend_Form_Element_Multiselect) {
             $element->setAttrib('class', $element->getAttrib('class') . ' field-multiselect');
         } elseif ($element instanceof Zend_Form_Element_Select) {
             $element->setAttrib('class', $element->getAttrib('class') . ' field-select');
         }
         if ($element instanceof Zend_Form_Element_Textarea) {
             $element->setAttrib('class', $element->getAttrib('class') . ' field-textarea');
         }
         if ($element instanceof Zend_Form_Element_File) {
             $element->setAttrib('class', $element->getAttrib('class') . ' field-file');
         }
         $element->setDecorators($decorators);
         if ($element instanceof Zend_Form_Element_Button) {
             $element->setDecorators(array(array('ViewScript', array('viewScript' => 'centurion/form/_button.phtml'))));
         }
     }
     return $this;
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:43,代码来源:Form.php

示例7: getCssClass

 /**
  * Retorna um array com as classes CSS utilizadas em um Zend_Form_Element
  * @param Zend_Form_Element $element elemento a ser consultado
  * @return array Retorna um array com cada classe encontrada
  * @author Jhonatan Morais <jhonatanvinicius@gmail.com>
  */
 public function getCssClass(Zend_Form_Element $element, $fromDecorator = null)
 {
     if (is_null($fromDecorator)) {
         return explode(' ', $element->getAttrib('class'));
     }
     return explode(' ', $element->getDecorator($fromDecorator)->getOption('class'));
 }
开发者ID:getJv,项目名称:ModuleTeste,代码行数:13,代码来源:MyBootstrapUtils.php

示例8: _addClassNameToElement

 /**
  * Add a specific class name to an element.
  *
  * @param Zend_Form_Element $element
  * @param string $className
  * @return void
  */
 private function _addClassNameToElement(Zend_Form_Element $element, $className)
 {
     $existingClassName = $element->getAttrib('class');
     $newClassName = strpos($existingClassName, $className) !== false ? $existingClassName : "{$existingClassName} {$className}";
     $element->setAttrib('class', $newClassName);
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:13,代码来源:Form.php

示例9: setClassToAnElement

 /**
  * Set an error class into element HtmlTag decorator
  *
  * @param Zend_Form_Element $element Element to 'decorate' for the error.
  * @param string $styleClass CSS class name.
  *
  * @return void
  */
 protected function setClassToAnElement(Zend_Form_Element $element, $styleClass)
 {
     $htmlTagDecorator = $element->getDecorator('HtmlTag');
     if (!empty($htmlTagDecorator)) {
         $class = $htmlTagDecorator->getOption('class');
         $htmlTagDecorator->setOption('class', $class . ' ' . $styleClass);
     }
     $element->setAttrib('class', $element->getAttrib('class') . ' ' . $styleClass);
 }
开发者ID:dafik,项目名称:dfi,代码行数:17,代码来源:Form.php


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