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


PHP Zend_Form_Element::addDecorator方法代码示例

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


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

示例1: init

 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->setAttribs(array('class' => 'form-horizontal'));
     $decoratorField = new My_Decorator_FieldLogin();
     $elements = array();
     // Add email field
     $input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email'));
     $validator = new Zend_Validate_EmailAddress();
     $validator->setOptions(array('domain' => false));
     $input->addValidators(array($validator, new Zend_Validate_NotEmpty()));
     $input->addDecorator($decoratorField);
     $elements[] = $input;
     // Add password field
     $input = new Zend_Form_Element_Password('password', array('required' => true, 'label' => 'Password:', 'id' => 'password', 'class' => 'form-control', 'placeholder' => 'Your password..'));
     $input->addValidators(array(new Zend_Validate_NotEmpty()));
     $input->addDecorator($decoratorField);
     $elements[] = $input;
     // Add checkbox field
     $input = new Zend_Form_Element_Checkbox('rememberMe', array('label' => 'Remember me', 'id' => 'rememberMe', 'class' => 'checkbox', 'type' => 'checkbox'));
     $decoratorCheckBox = new My_Decorator_CheckBox();
     $input->addDecorator($decoratorCheckBox);
     $elements[] = $input;
     $input = new Zend_Form_Element('resetpass', array('label' => 'Reset your password', 'id' => 'resetpass', 'class' => 'form-control', 'value' => 'resetpass'));
     $input->addDecorator(new My_Decorator_AnchoraForm());
     $elements[] = $input;
     //Add Submit button
     $input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'Login'));
     $input->addDecorator($decoratorField);
     $elements[] = $input;
     $this->addElements($elements);
     $this->addDisplayGroup(array('email', 'password', 'resetpass', 'rememberMe', 'submit'), 'displgrp', array('decorators' => array('FormElements', 'Fieldset')));
 }
开发者ID:cioionut,项目名称:products-webEcommerce,代码行数:34,代码来源:Login.php

示例2: addDefaultDecorators

 /**
  * Adds default decorators to an existing element
  * 
  * @param Zend_Form_Element $element
  */
 public static function addDefaultDecorators(Zend_Form_Element $element)
 {
     $fqName = $element->getName();
     if (null !== ($belongsTo = $element->getBelongsTo())) {
         $fqName = $belongsTo . '-' . $fqName;
     }
     $element->addDecorator('Description', array('tag' => 'p', 'class' => 'description', 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div', 'id' => $fqName . '-element', 'class' => 'form-element'))->addDecorator('Label', array('tag' => 'div', 'tagOptions' => array('id' => $fqName . '-label', 'class' => 'form-label')))->addDecorator('HtmlTag2', array('tag' => 'div', 'id' => $fqName . '-wrapper', 'class' => 'form-wrapper'));
 }
开发者ID:nhochong,项目名称:qlkh-sgu,代码行数:13,代码来源:Form.php

示例3: createTaskElement

 /**
  * Will set up a task-element and decorators
  * @param string $id
  * @param array $values
  * @param array $attribs
  * @return Zend_Form_Element
  */
 protected function createTaskElement($id, $values, $isNew = false)
 {
     $elm = new Zend_Form_Element((string) $id);
     $elm->clearDecorators();
     $elm->addDecorator(new My_Decorator_TaskElement());
     $elm->addDecorator('Errors', array('placement' => 'prepend'));
     // add configured validator
     $validator = new My_Validator_TaskElement();
     $validator->setIsNew($isNew);
     $elm->addValidator($validator);
     return $elm;
 }
开发者ID:TBeijen,项目名称:Zend_Form_Dynamic,代码行数:19,代码来源:My_SubForm_TaskDay.php

示例4: getSaveProductForm

 public function getSaveProductForm($id)
 {
     $form = new Zend_Form();
     //get product whitch want update
     $productMapper = new Application_Model_ProductMapper();
     $product = new Application_Model_Product();
     if ($id) {
         $product = $productMapper->getProductById($id);
     }
     // Set the method for the display form to POST
     $form->setMethod('post');
     $form->setAttribs(array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data'));
     $decoratorField = new My_Decorator_Field();
     $elements = array();
     //Add id hidden field
     $input = new Zend_Form_Element_Hidden('id', array('value' => $id));
     $elements[] = $input;
     // Add name field
     $input = new Zend_Form_Element_Text('name', array('required' => true, 'label' => 'Name:', 'id' => 'name', 'placeholder' => 'Type something..', 'value' => $product->getName(), 'class' => 'form-control'));
     $input->addValidators(array(new Zend_Validate_Alnum(), new Zend_Validate_NotEmpty()));
     $input->addDecorator($decoratorField);
     $elements[] = $input;
     // Add category field
     $select = new Zend_Form_Element_Select('category_id', array('required' => true, 'label' => 'Category:', 'id' => 'category', 'class' => 'form-control'));
     $categoryMapper = new Application_Model_CategoryMapper();
     $categories = $categoryMapper->fetchAll();
     foreach ($categories as $category) {
         $select->addMultiOption($category->getId(), $category->getName());
     }
     // set selected option
     $select->setValue($product->getCategoryId());
     $select->addDecorator($decoratorField);
     $elements[] = $select;
     $currencyMapper = new Application_Model_CurrencyMapper();
     $currency = $currencyMapper->getDefaultCurrency();
     // Add Price field
     $input = new Zend_Form_Element_Text('price', array('required' => true, 'label' => 'Price in ' . $currency->getCode() . ':', 'id' => 'price', 'placeholder' => 'Type something..', 'value' => number_format((double) $product->price, 2), 'class' => 'form-control', 'min' => self::MIN, 'max' => self::MAX, 'step' => 'any', 'type' => 'number'));
     $min = new Zend_Validate_LessThan(self::MAX);
     $max = new Zend_Validate_GreaterThan(self::MIN);
     $input->addValidators(array(new Zend_Validate_Float(), $min, $max, new Zend_Validate_NotEmpty()));
     $input->addDecorator($decoratorField);
     $elements[] = $input;
     if ($id) {
         //Add File field
         if ($product->file) {
             $input = new Zend_Form_Element('file', array('label' => 'File:', 'id' => 'file', 'class' => 'form-control', 'value' => $product->file));
             $input->addDecorator(new My_Decorator_AnchoraFileForm());
             $elements[] = $input;
         } else {
             $input = new Zend_Form_Element_File('file', array('label' => 'File:', 'id' => 'file', 'class' => 'form-control'));
             $input->addDecorator($decoratorField);
             $elements[] = $input;
         }
         //Add Image field
         if ($product->image) {
             $input = new Zend_Form_Element('image', array('label' => 'Image:', 'id' => 'image', 'class' => 'form-control', 'value' => $product->image));
             $input->addDecorator(new My_Decorator_ImageForm());
             $elements[] = $input;
         } else {
             $input = new Zend_Form_Element_File('image', array('label' => 'Image:', 'id' => 'image', 'class' => 'form-control'));
             $input->addDecorator($decoratorField);
             $elements[] = $input;
         }
     } else {
         //Add File field
         $input = new Zend_Form_Element_File('file', array('label' => 'File:', 'id' => 'file', 'class' => 'form-control'));
         $input->addDecorator($decoratorField);
         $elements[] = $input;
         //Add Image field
         $input = new Zend_Form_Element_File('image', array('label' => 'Image:', 'id' => 'image', 'class' => 'form-control'));
         $input->addDecorator($decoratorField);
         $elements[] = $input;
     }
     //Add Description field
     $input = new Zend_Form_Element_Textarea('description', array('label' => 'Description:', 'id' => 'description', 'class' => 'form-control', 'value' => $product->description));
     $input->addDecorator($decoratorField);
     $elements[] = $input;
     //Add Submit button
     if (!$id) {
         $input = new Zend_Form_Element_Submit('submit', array('Label' => ' ', 'class' => 'btn btn-success', 'value' => 'Add New Product'));
     } else {
         $input = new Zend_Form_Element_Submit('submit', array('Label' => ' ', 'class' => 'btn btn-info', 'value' => 'Update Product'));
     }
     $input->addDecorator($decoratorField);
     $elements[] = $input;
     $form->addElements($elements);
     $form->addDisplayGroup(array('name', 'category_id', 'price', 'currency_id', 'file', 'image', 'description', 'submit'), 'displgrp', array('legend' => 'Add Products', 'decorators' => array('FormElements', 'Fieldset')));
     return $form;
 }
开发者ID:cioionut,项目名称:products-webEcommerce,代码行数:89,代码来源:ProductsController.php

示例5: setupSingleElement

 /**
  * Setup per-element properties like labels, and classes
  */
 protected function setupSingleElement(Zend_Form_Element $elm)
 {
     // determine if this element has an error. (Will be used below)
     $elmHasError = count($elm->getMessages()) > 0;
     // set element values from the language pack
     $elm->setLabel($this->lang->get('form.label.' . $elm->getName()));
     // display info about required length if validator exists
     if ($elm->getValidator('StringLength')) {
         $elm->setDescription(sprintf($this->lang->get('form.description.' . $elm->getName()), $elm->getValidator('StringLength')->getMin(), $elm->getValidator('StringLength')->getMax()));
     } else {
         $elm->setDescription($this->lang->get('form.description.' . $elm->getName()));
     }
     // Duplicating type attr to classname in case we need to support IE6
     // and want to be able to directly target the element without using
     // input[type=text]
     $zendType = $elm->getType();
     $className = strtolower(substr($zendType, strrpos($zendType, '_') + 1));
     $elm->setAttrib('class', $className);
     // wrap this stuff up in a html div with class 'element'
     $elm->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'element'));
     // determine if element has error and use that to determine prefix char.
     // 1. There seems to be no way to add html to the reqPrefix
     // 2. There seems to be no way to add a custom classname to the div tag
     if ($elm->getName() != 'submit') {
         $reqChar = $elmHasError ? '! ' : '* ';
         $elm->addDecorator('Label', array('placement' => 'prepend', 'tag' => 'div', 'requiredPrefix' => $reqChar));
     }
     // use custom error decorator that attempts to replace default error
     // messages by the ones supplied by My_LanguagaPack
     $errorDecorator = new My_Decorator_Errors();
     $errorDecorator->setLanguagePack($this->lang);
     $elm->addDecorator($errorDecorator);
     // wrap everything so far in a li tag, give it class error if elm has error
     // ATT: using array to create alias for allready used HtmlTag decorator
     $liClass = $elmHasError ? 'error' : '';
     $elm->addDecorator(array('outerLi' => 'HtmlTag'), array('tag' => 'li', 'class' => $liClass));
 }
开发者ID:TBeijen,项目名称:Zend_Form_Without_MVC,代码行数:40,代码来源:My_Form_Renderer_Edit.php

示例6: decorateElement

 public function decorateElement(Zend_Form_Element $element)
 {
     if (!$element instanceof Zend_Form_Element_File) {
         $element->addDecorator('ViewHelper');
     }
     $element->addDecorator('HtmlTag', array('tag' => 'div'));
     $element->addDecorator('Label', array('tag' => null));
     $element->addDecorator(array('wrapper' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group col-sm-3'));
     return $element;
 }
开发者ID:abdala,项目名称:la,代码行数:10,代码来源:Form.php


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