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


PHP Zend_Form::setElementDecorators方法代码示例

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


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

示例1: setupElementsCommon

 /**
  * Setup decorators and properties common for all elements
  */
 protected function setupElementsCommon()
 {
     $viewElementDecorator = new My_Decorator_ViewElement();
     $viewElementDecorator->setLanguagePack($this->lang);
     $this->form->clearDecorators();
     $this->form->setElementDecorators(array($viewElementDecorator));
 }
开发者ID:TBeijen,项目名称:Zend_Form_Without_MVC,代码行数:10,代码来源:My_Form_Renderer_View.php

示例2: getForm

 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report5Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_REPORTPLANKIND');
     $e = new Zend_Form_Element_Select('reportplankind', array('label' => 'Звіт/план', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUFORM', false);
     $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUBASIS', false);
     $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRYTYPE', true);
     $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     if (@(!$this->params['establishment'])) {
         $e = new Zend_Form_Element_Checkbox('indpapers', array('label' => 'Індивідуальні аркуші'));
         $form->addElement($e);
     }
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 5));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:33,代码来源:Report5.php

示例3: getForm

 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report4Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_PLAN_YEAR');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Період', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUFORM', false);
     $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUBASIS', false);
     $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRYTYPE', false);
     $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 4));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:26,代码来源:Report4.php

示例4: getMailForm

 public static function getMailForm($docid)
 {
     $form = new Zend_Form();
     $form->setMethod('post')->setAttrib('onsubmit', 'return checkReply(this);')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'zend_form')), 'Form'));
     $form->addElements(array(array('select', 'to', array('label' => 'To', 'required' => true, 'multiOptions' => array_merge(array('' => ''), array_keys(self::getRecipients($docid))))), array('text', 'replyto', array('label' => 'Your e-mail address', 'validators' => array(array('EmailAddress')))), array('textarea', 'body', array('label' => 'Message body', 'required' => true, 'rows' => '7', 'cols' => '70', 'validators' => array(array('StringLength', true, array(0, 5000))), 'filters' => array('StringTrim')))));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))));
     $form->addElements(array(array('captcha', 'captcha', array('label' => 'Enter safety code', 'required' => true, 'ignore' => true, 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 5, 'timeout' => 600), 'decorators' => array('Captcha', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))))), array('submit', 'submit', array('label' => 'Send', 'decorators' => array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array(array('Label' => 'HtmlTag'), array('tag' => 'td', 'placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))))));
     return $form;
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:9,代码来源:Mail.php

示例5: setFormDefaults

 /**
  * Set Form defaults
  * - disable default decorators
  * - set form & displaygroup decorators
  * - set needed prefix path for bootstrap decorators
  * - set form element decorators
  *
  * @param Zend_Form $form The form instance.
  * @param string $format Standard, minimal, table.
  *
  * @return void
  */
 protected static function setFormDefaults(Zend_Form $form, $format)
 {
     $form->setDisableLoadDefaultDecorators(true);
     $form->setDisplayGroupDecorators(self::$_DisplayGroupDecorator[$format]);
     $form->setDecorators(self::$_FormDecorator[$format]);
     if (self::BOOTSTRAP == $format || self::BOOTSTRAP_MINIMAL == $format) {
         $form->addElementPrefixPath('Dfi_Form_Decorator', 'Dfi/Form/Decorator', Zend_Form::DECORATOR);
         $form->addPrefixPath('Dfi_Form_Decorator', 'Dfi/Form/Decorator', Zend_Form::DECORATOR);
     }
     $form->setElementDecorators(self::$_ElementDecorator[$format]);
     return;
 }
开发者ID:dafik,项目名称:dfi,代码行数:24,代码来源:Decorator.php

示例6: getForm

 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod(Zend_Form::METHOD_POST);
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'requests/reqForm.phtml'))));
     $items = $this->getGuideYears();
     $e = new Zend_Form_Element_Select('year', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'value' => reset($items)));
     $form->addElement($e);
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити'));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:13,代码来源:Requests.php

示例7: getInfoForm

 public function getInfoForm()
 {
     $form = new Zend_Form();
     $form->setAction('')->setMethod(Zend_Form::METHOD_POST)->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'import/infoForm10.phtml'), 'Form')));
     $e = new Zend_Form_Element_Hidden('step', array('value' => 2));
     $form->addElement($e);
     $e = new Zend_Form_Element_Hidden('filename');
     $form->addElement($e);
     $e = new Zend_Form_Element_Hidden('validreports');
     $form->addElement($e);
     $e = new Zend_Form_Element_Submit('submit', array('label' => 'Далі'));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper'));
     return $form;
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:16,代码来源:Import10.php

示例8: getForm

 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report9Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 9));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:17,代码来源:Report9.php

示例9: indexAction

 /**
  * The main workshop page.  It has the list of all the workshops that are 
  * available in the system.
  *
  */
 public function indexAction()
 {
     $this->view->acl = array('workshopList' => $this->_helper->hasAccess('workshop-list'));
     $get = Zend_Registry::get('getFilter');
     $form = new Zend_Form();
     $form->setAttrib('id', 'workshopForm')->setMethod(Zend_Form::METHOD_GET)->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'filterForm')), 'Form'));
     $searchField = $form->createElement('text', 'search', array('label' => 'workshop-index-index:searchWorkshops'));
     $searchField->setRequired(false)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($get->search) ? $get->search : '');
     $category = new Category();
     $categoryList = $category->fetchAll(null, 'name');
     $categories = $form->createElement('select', 'categoryId');
     $categories->addMultiOption('', '-- Search By Category -- ');
     foreach ($categoryList as $c) {
         $categories->addMultiOption($c['categoryId'], $c['name']);
     }
     $categories->setValue(isset($get->categoryId) ? $get->categoryId : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'workshop-index-index:search'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $form->addElements(array($searchField, $categories));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit));
     $this->view->form = $form;
     $searchTerm = new Search_Term();
     $workshops = array();
     if ($get->search != '' || $get->categoryId != 0) {
         $workshop = new Workshop();
         $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
         if ($get->search != '') {
             $query->addTerm(new Zend_Search_Lucene_Index_Term($get->search), true);
         }
         if ($get->categoryId != 0) {
             $query->addTerm(new Zend_Search_Lucene_Index_Term($get->categoryId, 'categoryId'), true);
         }
         $workshops = $workshop->search($query);
         $searchTerm->increment($get->search);
         $this->view->searchTerm = $get->search;
     }
     $this->view->workshops = $workshops;
     $this->view->topTerms = $searchTerm->getTopSearchTerms(10);
     $this->view->layout()->setLayout('search');
     $this->view->layout()->rightContent = $this->view->render('index/top-terms.phtml');
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css');
     $this->_helper->pageTitle("workshop-index-index:title");
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:49,代码来源:IndexController.php

示例10: getForm

 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report8Form.phtml'))));
     $items = $this->getPeriodItems('REQ_EDUSTAT_FAIL');
     $e = new Zend_Form_Element_Select('period', array('label' => 'На дату', 'multiOptions' => $items, 'required' => true));
     $form->addElement($e);
     $items = $this->getGuideItems('T_DEPARTMENT', true);
     $e = new Zend_Form_Element_Select('department', array('label' => 'Факультет', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 8));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:20,代码来源:Report8.php

示例11: getForm

 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report1Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Період', 'multiOptions' => $items, 'required' => true));
     $form->addElement($e);
     $items = $this->getGuideItems('T_STRUCTURE_ITEM', true, false, 'CT.TITLE');
     $e = new Zend_Form_Element_Select('establishment', array('label' => 'Установа', 'multiOptions' => $items));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUFORM', true);
     $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUBASIS', true);
     $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRY', true);
     $e = new Zend_Form_Element_Select('country', array('label' => 'Громадянство (країна)', 'multiOptions' => $items));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRYTYPE', true);
     $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDULEVEL');
     $e = new Zend_Form_Element_MultiCheckbox('edulevel', array('label' => 'Рівень підготовки', 'multiOptions' => $items));
     $e->setValue(array_keys($items));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 1));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     $auth = Zend_Auth::getInstance();
     $ident = $auth->getIdentity();
     if ($ident->STRUCTURE_CODE != 0) {
         $form->getElement('establishment')->setValue($ident->STRUCTUREID);
     }
     return $form;
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:41,代码来源:Report1.php

示例12: form

 /**
  * Gets the form for adding and editing a location
  *
  * @param array $values
  * @return Zend_Form
  */
 public function form($values = array())
 {
     $form = new Zend_Form();
     $form->setAttrib('id', 'locationTypeForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $name = $form->createElement('text', 'name', array('label' => 'Name:'));
     $name->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setValue(isset($values['name']) ? $values['name'] : '');
     //        $status = $form->createElement('select', 'status', array('label' => 'Status:'));
     //        $status->addMultiOption('enabled', 'Enabled');
     //        $status->addMultiOption('disabled', 'Disabled');
     //        $status->setValue((isset($values['status']) ? $values['status'] : 'enabled'));
     //        $capacity = $form->createElement('text', 'capacity', array('label' => 'Capacity:'));
     //        $capacity->setRequired(true)
     //                 ->addFilter('StringTrim')
     //                 ->addFilter('StripTags')
     //                 ->addValidator('Digits')
     //                 ->setAttrib('maxlength', '64')
     //                 ->setValue((isset($values['capacity']) ? $values['capacity'] : ''));
     //        $address = $form->createElement('text', 'address', array('label' => 'Address:'));
     //        $address->setRequired(true)
     //                ->addFilter('StringTrim')
     //                ->addFilter('StripTags')
     //                ->setAttrib('maxlength', '255')
     //                ->setValue((isset($values['address']) ? $values['address'] : ''));
     $description = $form->createElement('textarea', 'description', array('label' => 'Description:'));
     $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 300px;')->setValue(isset($values['description']) ? $values['description'] : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->addElements(array($name, $description));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     if (isset($values['typeId'])) {
         $locationId = $form->createElement('hidden', 'typeId');
         $locationId->setValue($values['typeId']);
         $locationId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
         $form->addElement($locationId);
     }
     return $form;
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:46,代码来源:LocationType.php

示例13: form

 public function form($values = array())
 {
     $form = new Zend_Form();
     $form->setAttrib('id', 'categoryForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $name = $form->createElement('text', 'name', array('label' => 'Name:'));
     $name->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setValue(isset($values['name']) ? $values['name'] : '');
     $description = $form->createElement('textarea', 'description', array('label' => 'Description:'));
     $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 300px;')->setValue(isset($values['description']) ? $values['description'] : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->addElements(array($name, $description));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     if (isset($values['categoryId'])) {
         $categoryId = $form->createElement('hidden', 'categoryId');
         $categoryId->setValue($values['categoryId']);
         $categoryId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
         $form->addElement($categoryId);
     }
     return $form;
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:23,代码来源:WorkshopCategory.php

示例14: form

 /**
  * Gets the form for adding and editing a location
  *
  * @param array $values
  * @return Zend_Form
  */
 public function form($values = array())
 {
     require_once APPLICATION_PATH . '/models/Workshop/Category.php';
     $form = new Zend_Form();
     $form->setAttrib('id', 'workshopForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $title = $form->createElement('text', 'title', array('label' => 'Workshop Title:'));
     $title->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '255')->setValue(isset($values['title']) ? $values['title'] : '');
     $group = $form->createElement('select', 'group', array('label' => 'Offered By:'));
     $group->addMultiOption('groupId1', 'Test Group1');
     $group->addMultiOption('groupId2', 'Test Group2');
     $group->setValue(isset($values['group']) ? $values['group'] : null);
     //TODO: change this to add all the enabled groups in the database
     $tags = $form->createElement('text', 'tags', array('label' => 'Tags:'));
     $tags->setRequired(false)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($values['tags']) ? implode(', ', $values['tags']) : '');
     $status = $form->createElement('select', 'status', array('label' => 'Status:'));
     $status->addMultiOption('enabled', 'Enabled');
     $status->addMultiOption('disabled', 'Disabled');
     $status->setValue(isset($values['status']) ? $values['status'] : 'enabled');
     $category = new Category();
     $categoryList = $category->fetchAll(null, 'name');
     $categories = $form->createElement('select', 'categoryId', array('label' => 'Worshop Category: '));
     $categories->setRequired(true);
     foreach ($categoryList as $category) {
         $categories->addMultiOption($category->categoryId, $category->name);
     }
     $categories->setValue(isset($values['categoryId']) ? $values['categoryId'] : '');
     $prerequisites = $form->createElement('textarea', 'prerequisites', array('label' => 'workshop-index-add:preRequisites'));
     $prerequisites->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 200px;')->setValue(isset($values['prerequisites']) ? $values['prerequisites'] : '');
     $featured = $form->createElement('checkbox', 'features', array('label' => 'Featured?'));
     $featured->setValue(isset($values['featured']) ? $values['featured'] : null);
     $description = $form->createElement('textarea', 'description', array('label' => 'Description:'));
     $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 200px;')->setValue(isset($values['description']) ? $values['description'] : '');
     $editors = $form->createElement('multiselect', 'editors', array('label' => 'Workshop Editors:'));
     $editors->setRequired(false)->setAttrib('size', '10');
     $account = new Ot_Account();
     $accounts = $account->fetchAll(null, array('lastName', 'firstName'));
     foreach ($accounts as $a) {
         $editors->addMultiOption($a->accountId, $a->firstName . ' ' . $a->lastName . ' (' . $a->username . ')');
     }
     $editors->setValue(isset($values['editors']) ? $values['editors'] : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->addElements(array($status, $title, $categories, $group, $tags, $description, $prerequisites, $editors));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     if (isset($values['workshopId'])) {
         $workshopId = $form->createElement('hidden', 'workshopId');
         $workshopId->setValue($values['workshopId']);
         $workshopId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
         $form->addElement($workshopId);
     }
     return $form;
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:61,代码来源:Workshop.php

示例15: array

$file->setLabel('File')->setRequired(true)->setValueDisabled(False)->addValidator('Extension', FALSE, 'jpg,jpeg')->addValidator('Size', false, array('min' => 20, 'max' => 20000000));
$file->getValidator('Extension')->setMessage('JPEGs only');
// Create text area for message
$message = new Zend_Form_Element_Textarea('message');
$message->setRequired(TRUE)->setAttrib('id', 'message')->addErrorMessage('Please specify a message');
// Create a submit button
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Submit')->setAttrib('id', 'submit');
// Set the ViewScript decorator for the form and tell it which
// template file to use
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'form-contact.tpl.php'))));
// Add the form elements AFTER the viewscript decorator has been set
$form->addElements(array($file, $message, $submit));
// Get rid of all element decorators except for ViewHelper to render
// the individual elements and Errors decorator to render the errors.
$form->setElementDecorators(array('ViewHelper', 'Errors'));
// The file element requires the File decorator instead of the
// ViewHelper decorator
$file->setDecorators(array('File', 'Errors'));
// Create an instance of Zend_View and set the directory
// for the template files
$view = new Zend_View();
$view->setScriptPath(__DIR__);
// Tell all the elements in the form which view to use when rendering
foreach ($form as $item) {
    $item->setView($view);
}
// process or display the form
if (isset($_POST['submit']) && $form->isValid($_POST)) {
    $uploadHandler = new Zend_File_Transfer_Adapter_Http();
    $uploadHandler->setDestination(__DIR__ . '/uploads/');
开发者ID:rmuktader,项目名称:zf-stand-alone-upload-form,代码行数:31,代码来源:form.php


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