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


PHP Zend_Form::getElements方法代码示例

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


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

示例1: editformAction

 /**
  * editformAction
  * @author Thomas Schedler <tsh@massiveart.com>
  * @version 1.0
  */
 public function editformAction()
 {
     $this->core->logger->debug('users->controllers->ResourceController->editformAction()');
     try {
         $arrGroups = $this->getModelUsers()->getResourceGroups($this->getRequest()->getParam('id'));
         if (count($arrGroups) > 0) {
             $this->arrGroups = array();
             foreach ($arrGroups as $objGroup) {
                 $this->arrGroups[] = $objGroup->idGroups;
             }
         }
         $this->initForm();
         $this->objForm->setAction('/zoolu/users/resource/edit');
         $this->objResource = $this->getModelUsers()->getResourceTable()->find($this->getRequest()->getParam('id'))->current();
         foreach ($this->objForm->getElements() as $objElement) {
             $name = $objElement->getName();
             if (isset($this->objResource->{$name})) {
                 $objElement->setValue($this->objResource->{$name});
             }
         }
         $this->view->form = $this->objForm;
         $this->view->formTitle = $this->core->translate->_('Edit_Resource');
         $this->renderScript('form.phtml');
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
开发者ID:BGCX261,项目名称:zoolu-svn-to-git,代码行数:32,代码来源:ResourceController.php

示例2: saveFormData

 public function saveFormData(Zend_Form $form)
 {
     $item = $this->_model;
     $item->setOptions($form->getValues());
     if ($this->_request->getParam('contentMarkdown')) {
         $context_html = Michelf\MarkdownExtra::defaultTransform($this->_request->getParam('contentMarkdown'));
         $item->setContentHtml($context_html);
     }
     $fullPath = $this->_request->getParam('path');
     if ($this->_request->getParam('parentId') != 0) {
         $parentCategory = $this->_modelMapper->find($this->_request->getParam('parentId'), new Pipeline_Model_PipelineCategories());
         if ($parentCategory) {
             $fullPath = $parentCategory->getFullPath();
         }
     }
     $item->setFullPath($fullPath);
     $this->setMetaData($item);
     $this->getModelMapper()->save($item);
     if ($item->getId() && $item->getId() != '') {
         $id = $item->getId();
     } else {
         $id = $this->getModelMapper()->getDbTable()->getAdapter()->lastInsertId();
     }
     $item = $this->getModelMapper()->find($id, $this->getModel());
     foreach ($form->getElements() as $key => $element) {
         if ($element instanceof Zend_Form_Element_File && $element->isUploaded()) {
             $item = $this->saveUploadFile($element, $item);
         }
     }
     return $item;
 }
开发者ID:Alpha-Hydro,项目名称:alpha-hydro-antares,代码行数:31,代码来源:PipelineCategoriesController.php

示例3: setFormElementTypeClasses

 /**
  * Sets each element with a class based on its type
  * 
  * @param Zend_Form $form
  */
 public static function setFormElementTypeClasses(Zend_Form $form)
 {
     foreach ($form->getElements() as $element) {
         $type = strtolower(array_pop(explode('_', $element->getType())));
         $class = isset($element->class) ? $element->class . ' ' : '';
         $class .= 'element-type-' . $type;
         $element->class = $class;
     }
 }
开发者ID:nhochong,项目名称:qlkh-sgu,代码行数:14,代码来源:Form.php

示例4: enhance

 /**
  * Adds unique IDs to all elements in the given form.
  *
  * @param Zend_Form $form
  */
 public function enhance(Zend_Form $form)
 {
     foreach ($form->getSubForms() as $subForm) {
         /* @var $subForm Zend_Form */
         $this->enhance($subForm);
     }
     foreach ($form->getElements() as $element) {
         /* @var $element Zend_Form_Element */
         $this->updateId($element);
     }
 }
开发者ID:matthimatiker,项目名称:molcomponents,代码行数:16,代码来源:UniqueId.php

示例5: testFormShouldOverloadToRenderDecorators

 /**
  * @group ZF-3217
  */
 public function testFormShouldOverloadToRenderDecorators()
 {
     $this->setupElements();
     $this->form->setView($this->getView());
     $html = $this->form->renderFormElements();
     foreach ($this->form->getElements() as $element) {
         $this->assertContains('id="' . $element->getFullyQualifiedName() . '"', $html, 'Received: ' . $html);
     }
     $this->assertNotContains('<dl', $html);
     $this->assertNotContains('<form', $html);
     $html = $this->form->renderForm('this is the content');
     $this->assertContains('<form', $html);
     $this->assertContains('</form>', $html);
     $this->assertContains('this is the content', $html);
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:18,代码来源:FormTest.php

示例6: serializeValues

 /**
  * Serialize form elements
  * @param Zend_Form $form Zend form, which value to serialize
  * @param DOMElement $domElement parent element where to create the "values" element
  */
 private function serializeValues($form, DOMElement $domElement)
 {
     $values = $domElement->ownerDocument->createElement("values");
     $domElement->appendChild($values);
     foreach ($form->getElements() as $name => $element) {
         $node = $domElement->ownerDocument->createElement("element");
         $node->setAttribute("name", $element->getFullyQualifiedName());
         if ($element->getAttrib("disabled")) {
             $node->setAttribute("disabled", "disabled");
         }
         $node->appendChild($domElement->ownerDocument->createElement('value', htmlspecialchars($element->getValue(), ENT_NOQUOTES)));
         $this->serializeErrors($element->getErrors(), $node);
         $values->appendChild($node);
     }
 }
开发者ID:kandy,项目名称:system,代码行数:20,代码来源:Form.php

示例7: editformAction

 /**
  * editformAction
  * @author Thomas Schedler <tsh@massiveart.com>
  * @version 1.0
  */
 public function editformAction()
 {
     $this->core->logger->debug('users->controllers->GroupController->editformAction()');
     try {
         /**
          * get permissions
          */
         $arrPermissions = $this->getModelUsers()->getGroupPermissions($this->getRequest()->getParam('id'));
         if (count($arrPermissions) > 0) {
             $this->arrPermissions = array();
             foreach ($arrPermissions as $objPermission) {
                 if (!array_key_exists('lang_' . $objPermission->idLanguages, $this->arrPermissions)) {
                     $this->arrPermissions['lang_' . $objPermission->idLanguages] = array('language' => $objPermission->idLanguages, 'permissions' => array($objPermission->idPermissions));
                 } else {
                     $this->arrPermissions['lang_' . $objPermission->idLanguages]['permissions'][] = $objPermission->idPermissions;
                 }
             }
         } else {
             $this->arrPermissions = array(array('language' => '', 'permissions' => ''));
         }
         /**
          * get groupType
          */
         $arrGroupTypes = $this->getModelUsers()->getGroupGroupTypes($this->getRequest()->getParam('id'));
         if (count($arrGroupTypes) > 0) {
             $this->arrGroupTypes = array();
             foreach ($arrGroupTypes as $objGroupType) {
                 $this->arrGroupTypes[] = $objGroupType->idGroupTypes;
             }
         } else {
             $this->arrGroupTypes = array();
         }
         $this->initForm();
         $this->objForm->setAction('/zoolu/users/group/edit');
         $this->objGroup = $this->getModelUsers()->getGroupTable()->find($this->getRequest()->getParam('id'))->current();
         foreach ($this->objForm->getElements() as $objElement) {
             $name = $objElement->getName();
             if (isset($this->objGroup->{$name})) {
                 $objElement->setValue($this->objGroup->{$name});
             }
         }
         $this->view->form = $this->objForm;
         $this->view->formTitle = $this->core->translate->_('Edit_Group');
         $this->renderScript('form.phtml');
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
开发者ID:BGCX261,项目名称:zoolu-svn-to-git,代码行数:53,代码来源:GroupController.php

示例8: formBootstrap

 public function formBootstrap(Zend_Form $form, $submitLabel = 'Valider')
 {
     $html = $form->renderForm(false);
     foreach ($form->getElements() as $element) {
         $element->getDecorator('label')->setOption('tag', null);
         // TODO retirer la class error du ul
         $html .= $element->getMessages() ? '<div class="form-group has-error">' : '<div class="form-group">';
         $html .= $element->renderLabel();
         $html .= $element->setAttrib('class', 'form-control')->renderViewHelper();
         if ($element->getMessages()) {
             $html .= '<div class="help-block">';
             $html .= $element->renderErrors();
             $html .= '</div>';
         }
         $html .= '</div>';
     }
     $html .= '<button type="submit" class="btn btn-primary">' . $submitLabel . '</button>';
     $html .= '</form>';
     return $html;
 }
开发者ID:bioub,项目名称:Formation_ZF1_Viveris_2016_02,代码行数:20,代码来源:FormBootstrap.php

示例9: build

 public static function build($formConfig)
 {
     $decorators = array();
     if ($formConfig->useInternalError) {
         $decorators[] = new Saf_Form_Zend_Helper_Error(array('class' => 'formErrors', 'id' => $newFormId . 'Errors', 'placement' => 'append', 'escape' => false));
     }
     $newForm = new Zend_Form();
     $newForm->setConfig($formConfig);
     $newForm->removeDecorator('HtmlTag');
     $newFormId = $newForm->getId();
     $formDecorator = $newForm->getDecorator('Form');
     $elementDecorator = $newForm->getDecorator('FormElements');
     $decorators[] = $elementDecorator;
     $decorators[] = $formDecorator;
     $newForm->setDecorators($decorators);
     foreach ($newForm->getElements() as $element) {
         self::fixElement($element);
     }
     return $newForm;
 }
开发者ID:jthurteau,项目名称:saf,代码行数:20,代码来源:Factory.php

示例10: _buildTable

 protected function _buildTable(Zend_Form $form)
 {
     # generate table header
     if ($this->_tableHeadersBuilt !== true) {
         if ($form instanceof Zend_Form_SubForm) {
             foreach ($form->getElements() as $eName => $e) {
                 if (isset($this->_tableHeaders[$eName])) {
                     throw new Exception(sprintf('Invalid sub-form (table row configuration) "%s" for table layout - table header already set for this column "%s"', $form->getName(), $eName));
                 }
                 $this->_tableHeaders[$eName] = $e->getLabel();
             }
             foreach ($form->getSubForms() as $formName => $subForm) {
                 $this->_buildTable($subForm);
             }
             return false;
         }
         # get headers from first sub-form
         $subform = $form->getSubForms();
         $subform = current($subform);
         $this->_buildTable($subform);
         $this->_tableHeadersBuilt = true;
     }
     if ($form instanceof Zend_Form_SubForm) {
         foreach ($form->getElements() as $eName => $e) {
             if ($this->getOption('doNotSetDecorators') !== true) {
                 $e->setDecorators(array('ViewHelper'));
             }
             if (isset($this->_tableCell[$eName])) {
                 throw new Exception(sprintf('Invalid sub-form (table row configuration) "%s" for table layout - table cell "%s" already set for row %d', $form->getName(), $eName, $this->_rowIndex));
             }
             $this->_tableCell[$eName] = $e;
         }
         foreach ($form->getSubForms() as $formName => $subForm) {
             $this->_buildTable($subForm);
         }
         return;
     }
     # $form is not instance of Zend_Form_SubForm
     $result = array();
     foreach ($form->getSubForms() as $formName => $subForm) {
         $this->_tableCell = array();
         $this->_rowIndex++;
         $this->_buildTable($subForm);
         if (empty($this->_tableCell)) {
             # no data generated from current subform
             continue;
         }
         $result[$this->_rowIndex] = $this->_tableCell;
     }
     if (empty($result)) {
         return '';
     }
     $tableRows = array();
     foreach ($result as $rowIndex => $row) {
         $elements = array();
         foreach ($this->_tableHeaders as $eName => $label) {
             if (!isset($row[$eName])) {
                 throw new Exception(sprintf('Invalid form "%s" for table layout - missing table cell "%s" for row %d', $form->getName(), $eName, $rowIndex));
             }
             # display messages in the same table cell as the input field
             $elements[] = implode('<br />', array_merge($row[$eName]->getMessages(), array($row[$eName]->render())));
         }
         $tableRows[] = '<tr><td>' . implode('</td><td>', $elements) . '</td></tr>' . "\n";
     }
     return '<table><tr><th>' . implode('</th><th>', $this->_tableHeaders) . '</th></tr>' . "\n" . implode('', $tableRows) . '</table>';
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:66,代码来源:Table.php

示例11: getActionForm

 /**
  * Get action form
  *
  * @return Zend_Form
  */
 private function getActionForm()
 {
     $translator = \Zend_Registry::get('container')->getService('translator');
     $form = new Zend_Form();
     $form->addElements(array(new Zend_Form_Element_Hash('csrf', array('decorators' => array('ViewHelper'))), new Zend_Form_Element_Hidden('name', array('decorators' => array('ViewHelper'))), new Zend_Form_Element_Select('multiaction', array('multioptions' => array('' => $translator->trans('Actions'), 'move' => $translator->trans('Move'), 'delete' => $translator->trans('Delete')), 'decorators' => array('ViewHelper'))), new Zend_Form_Element_Hidden('action', array('required' => true, 'validators' => array(array('inArray', true, array(array('copy', 'move', 'rename', 'delete', 'create-file', 'create-folder')))), 'decorators' => array('ViewHelper'))), new Zend_Form_Element_MultiCheckbox('file')));
     foreach ($form->getElements() as $elem) {
         $elem->removeDecorator('DtDdWrapper')->removeDecorator('Label');
     }
     return $form;
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:15,代码来源:TemplateController.php

示例12: getForm

 /**
  * @param unknown_type $formName
  * @param unknown_type $options
  * @throws Exception
  * @return Zend_Form
  */
 public function getForm($formName, $options = null, $useTemplate = false)
 {
     if (is_null(self::$_forms)) {
         if (is_file(APPLICATION_PATH . '/configs/forms.ini')) {
             $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/forms.ini');
         } else {
             $config = new Zend_Config(include_once APPLICATION_PATH . '/configs/forms.php');
         }
         $config = $config->toArray();
         self::$_forms = $config;
     }
     if (!array_key_exists($formName, $config)) {
         throw new Exception("Form not exist");
     }
     if ($useTemplate) {
         //$form = new Zend_Form_Template($config[$formName]);
         //$form->setTemplate($formName, $options);
         $form = new Zend_Form($config[$formName]);
         $elements = $form->getElements();
         foreach ($elements as &$element) {
             $element->removeDecorator('Label');
             $element->removeDecorator('HtmlTag');
             $element->removeDecorator('DtDdWrapper');
             $element->removeDecorator('Description');
             $element->removeDecorator('Errors');
             $element->addDecorator(array('data' => 'Errors'), array('tag' => 'p', 'class' => 'description'));
         }
         $filter = new Zend_Filter_Word_CamelCaseToDash();
         $formName = $filter->filter($formName);
         $options['viewScript'] = 'forms/' . $formName . '.phtml';
         $form->setDecorators(array(array('viewScript', $options)));
     } else {
         $form = new Zend_Form($config[$formName]);
         /*  $form->addElementPrefixPath('Zend_Decorator',
             'Zend/Decorator/',
             'decorator');
             $form->setDecorators(array('Default'));*/
         //Zend_Debug::dump($form->getDecorator('Errors'));
         /*$elements = $form->getElements();
                     foreach ($elements as &$element) {
         
                         $element->setDecorators(
                             array(
                             'ViewHelper',
                             'Errors',
                             array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element')),
                             'Label',
                             array(array('row' => 'HtmlTag'), array('tag' => 'li'))
                             )
                         );
         
                         //Zend_Debug::dump($element->getDecorator('Errors'));
         
                     };*/
         /*
                     $form->setElementDecorators(array(
                         'ViewHelper',
                         array('Errors', array('class' => 'help-inline control-error')),
                         array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'controls')),
                         array(array('label' => 'Label'), array('class' => 'control-label')),
                         array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'control-group')),
                     ));
         */
         // $form->addElement("text", "naem", $opt);
         /* $form->setDecorators(array(
                'FormElements',
                array('Form', array('class' => 'form-horizontal'))
            ));*/
         //Zend_Debug::dump($form);
         // вынести декораторы
     }
     $formAction = $form->getAction();
     $routes = $this->getRouterNames();
     $actionParams = array();
     if (is_array($options) && array_key_exists('actionParams', $options)) {
         $actionParams = $options['actionParams'];
     }
     if (in_array($formAction, $routes)) {
         if (array_key_exists("actionParams", $config[$formName]) && is_array($config[$formName]['actionParams'])) {
             $actionParams = $config[$formName]['actionParams'];
         }
         $form->setAction($this->_url($actionParams, $formAction));
     }
     //Zend_Debug::dump($form);
     return $form;
 }
开发者ID:sb15,项目名称:legacy-library,代码行数:92,代码来源:WebCore.php

示例13: getFormAsArray

 /**
  * Return an array of form elements.
  *
  * @param Zend_Form $form
  * @return array
  */
 public function getFormAsArray(Zend_Form $form)
 {
     $array = array();
     $array['action'] = $form->getAction();
     $array['method'] = $form->getMethod();
     foreach ($form->getElements() as $element) {
         $element->removeDecorator('HtmlTag');
         $element->removeDecorator('Label');
         $element->removeDecorator('DtDdWrapper');
         $array[$element->getName()] = $element;
     }
     return $array;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:19,代码来源:GlobalController.php

示例14: setTargetForm

 /**
  * Set a form populated with elements for filtering and validation of
  * the input elements
  *
  * @param \Zend_Form $form
  * @return \MUtil_Model_ModelTranslatorAbstract (continuation pattern)
  */
 public function setTargetForm(\Zend_Form $form)
 {
     $this->targetForm = $form;
     $this->_dateElementNames = array();
     $this->_checkForm($form->getElements());
     return $this;
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:14,代码来源:ModelTranslatorAbstract.php

示例15: hasCsrf

 /**
  * Checks if the provided form already contains a CSRF element.
  *
  * @param Zend_Form $form
  * @return boolean
  */
 protected function hasCsrf(Zend_Form $form)
 {
     foreach ($form->getElements() as $element) {
         /* @var $element Zend_Form_Element */
         if ($element instanceof Zend_Form_Element_Hash) {
             // Form already contains a CSRF token.
             return true;
         }
     }
     return false;
 }
开发者ID:matthimatiker,项目名称:molcomponents,代码行数:17,代码来源:Csrf.php


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