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


PHP Zend_Form_Element::setDecorators方法代码示例

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


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

示例1: addElement

 /**
  * Add element to stack
  *
  * @param  \Zend_Form_Element $element
  * @return \Zend_Form_DisplayGroup
  */
 public function addElement(\Zend_Form_Element $element)
 {
     $decorators = $element->getDecorators();
     $decorator = array_shift($decorators);
     $element->setDecorators(array($decorator, array('Description', array('class' => 'description')), 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')), array('Label'), array(array('labelCell' => 'HtmlTag'), array('tag' => 'td', 'class' => 'label')), array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'class' => $this->_alternate))));
     return parent::addElement($element);
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:13,代码来源:TabGroup.php

示例2: _renderElement

 /**
  * Renders an element with only the view helper decorator
  *
  * @param Zend_Form_Element $element
  */
 protected function _renderElement(Zend_Form_Element $element)
 {
     $element->setDecorators(array('ViewHelper'));
     return trim($element->render($this->getElement()->getView()));
 }
开发者ID:ngchie,项目名称:system,代码行数:10,代码来源:Addon.php

示例3: __construct

 public function __construct($options = null)
 {
     parent::__construct($options);
     $translate = Zend_Registry::get('Zend_Translate');
     $this->removeDecorator('DtDdWrapper');
     $this->setName('register_form');
     $this->setAttrib('id', 'register_form');
     $this->addElementPrefixPath('Oibs_Decorators', 'Oibs/Decorators/', 'decorator');
     $this->addElementPrefixPath('Oibs_Validators', 'OIBS/Validators/', 'validate');
     $city = new Zend_Form_Element_Text('city');
     $city->setLabel($translate->_("account-register-city"))->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty'))), array('Regex', true, array('/^[\\p{L}0-9.\\- ]*$/'))))->setDecorators(array('RegistrationDecorator'));
     $mailvalid = new Zend_Validate_EmailAddress();
     $mailvalid->setMessage('email-invalid', Zend_Validate_EmailAddress::INVALID);
     $mailvalid->setMessage('email-invalid-hostname', Zend_Validate_EmailAddress::INVALID_HOSTNAME);
     $mailvalid->setMessage('email-invalid-mx-record', Zend_Validate_EmailAddress::INVALID_MX_RECORD);
     $mailvalid->setMessage('email-dot-atom', Zend_Validate_EmailAddress::DOT_ATOM);
     $mailvalid->setMessage('email-quoted-string', Zend_Validate_EmailAddress::QUOTED_STRING);
     $mailvalid->setMessage('email-invalid-local-part', Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
     $mailvalid->setMessage('email-length-exceeded', Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
     $mailvalid->hostnameValidator->setMessage('hostname-invalid-hostname', Zend_Validate_Hostname::INVALID_HOSTNAME);
     $mailvalid->hostnameValidator->setMessage('hostname-local-name-not-allowed', Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
     $mailvalid->hostnameValidator->setMessage('hostname-unknown-tld', Zend_Validate_Hostname::UNKNOWN_TLD);
     $mailvalid->hostnameValidator->setMessage('hostname-invalid-local-name', Zend_Validate_Hostname::INVALID_LOCAL_NAME);
     $mailvalid->hostnameValidator->setMessage('hostname-undecipherable-tld', Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
     $email = new Zend_Form_Element_Text('email');
     $email->setLabel($translate->_("account-register-email"))->setRequired(true)->addFilter('StringtoLower')->addValidators(array($mailvalid))->addErrorMessage('email-invalid')->setDecorators(array('RegistrationDecorator'));
     $e_options = array("" => "account-select", "private_sector" => "account-register_private_sector", "public_sector" => "account-register_public_sector", "education_sector" => "account-register_education_sector", "student" => "account-register_student", "pentioner" => "account-register_pentioner", "other" => "account-register_other");
     $employment = new Zend_Form_Element_Select('employment');
     $employment->setLabel($translate->_("account-register-employment"))->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty')))))->addMultiOptions($e_options)->setDecorators(array('RegistrationDecorator'));
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel($translate->_("account-register-username"))->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty'))), array('StringLength', false, array(4, 16, 'messages' => array('stringLengthTooShort' => 'field-too-short', 'stringLengthTooLong' => 'field-too-long'))), new Oibs_Validators_UsernameExists('username'), new Oibs_Validators_Username('username')))->setDecorators(array('RegistrationDecorator'));
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel($translate->_("account-register-password"));
     $password->setRequired(true);
     $password->addValidators(array(new Oibs_Validators_RepeatValidator('confirm_password'), array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty'))), array('StringLength', false, array(4, 16, 'messages' => array('stringLengthTooShort' => 'field-too-short', 'stringLengthTooLong' => 'field-too-long')))));
     $password->setDecorators(array('RegistrationDecorator'));
     $confirm_password = new Zend_Form_Element_Password('confirm_password');
     $confirm_password->setLabel($translate->_("account-register-password_confirm"));
     $confirm_password->setRequired(true);
     $confirm_password->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty')));
     $confirm_password->addValidator('StringLength', false, array(4, 16, 'messages' => array('stringLengthTooShort' => 'field-too-short', 'stringLengthTooLong' => 'field-too-long')));
     $confirm_password->setDecorators(array('RegistrationDecorator'));
     $captcha = new Zend_Form_Element('captcha');
     $captcha->setDecorators(array('CaptchaDecorator'));
     $captcha_text = new Zend_Form_Element_Text('captcha_text');
     $captcha_text->setLabel($translate->_("account-register-enter_text"))->addValidators(array(new Oibs_Validators_CaptchaValidator(), array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty')))))->setRequired(true)->setDecorators(array('RegistrationDecorator'));
     $text = sprintf($translate->_("account-register-terms_and_privacy"), "terms", "privacy");
     // this solution sucks. the codes are in the translate block directly.
     // anyone think of a fix to move codes out of there?
     // - Joel
     $terms = new Zend_Form_Element_Checkbox('terms');
     $terms->setDescription($text)->setLabel("account-register-terms")->setChecked(false)->setRequired(true)->addValidators(array(new Oibs_Validators_CheckboxValidator()))->setDecorators(array('RegistrationTermsDecorator'));
     // checkboxes always have a value of 1or0, this is a "feature" in ZF
     // custom validator is a workaround
     // -Joel
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel($translate->_("account-register-submit"))->removeDecorator('DtDdWrapper')->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'registration_submit_div'))))->setAttrib('class', 'registration_form_submit_' . $translate->getLocale());
     $this->addElements(array($username, $password, $confirm_password, $city, $email, $employment, $captcha, $captcha_text, $terms, $submit));
     /*$this->addDisplayGroup(array('username', 'password', 'confirm_password'), 'account_information');
       $this->account_information->setLegend('register-account-information');
       $this->account_information->removeDecorator('DtDdWrapper');
       $this->addDisplayGroup(array('city', 'email', 'employment'), 'personal_information');
       $this->personal_information->removeDecorator('DtDdWrapper');
       $this->personal_information->setLegend('register-personal-information');
       
       $this->addDisplayGroup(array('captcha', 'captcha_text', 'terms', 'submit'), 'confirmations');
       $this->confirmations->removeDecorator('DtDdWrapper');
       $this->confirmations->setLegend('register-confirmations');*/
 }
开发者ID:jannev,项目名称:site,代码行数:69,代码来源:RegistrationForm.php

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

示例5: _setDecorator

 protected function _setDecorator(Zend_Form_Element $element)
 {
     $search = array('submit', 'reset', 'checkbox', 'radio', 'textarea', 'password');
     $replace = array('button', 'button', 'checkbox', 'checkbox', 'text', 'text');
     $type = strtolower(str_replace('Zend_Form_Element_', '', $element->getType()));
     $type = str_replace($search, $replace, $type);
     if (key_exists($type, $this->_standardDecorators)) {
         $element->setDecorators($this->_standardDecorators[$type]);
         if (method_exists($element, 'hasErrors') && $element->hasErrors()) {
             $decorator = $element->getDecorator('HtmlTag');
             if (is_object($decorator)) {
                 $decorator->setOption('class', $decorator->getOption('class') . ' ' . $this->_errorClass);
             }
         }
     } else {
         $element->loadDefaultDecorators();
     }
 }
开发者ID:laiello,项目名称:digitalus-cms,代码行数:18,代码来源:Form.php


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