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


PHP Form::getElements方法代码示例

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


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

示例1: __invoke

 public function __invoke(Form $form)
 {
     $form->setAttribute('class', self::DEFAULT_FORM_CLASS);
     foreach ($form->getElements() as $element) {
         /*
          * controls how far the form indents into
          * the page using Twitter:Bootstrap CSS
          *
          */
         $defLabelAttributes = array('class' => self::DEFAULT_LABEL_CLASS);
         $element->setLabelAttributes($defLabelAttributes);
         $element->setAttribute('class', self::DEFAULT_INPUT_CLASS);
         /*
          * set the id attribute of all inputs to be equal to their names
          *
          * makes life simple when trying to make the view
          * dynamic
          */
         $element->setAttribute('id', $element->getName());
     }
     /*
      * the submit button is a little different, it uses
      * a button class to proper rendering
      *
      */
     $form->get('submit')->setAttribute('class', self::DEFAULT_SUBMIT_BUTTON_CLASS);
     return $form;
 }
开发者ID:decmade,项目名称:zendAbacAcl,代码行数:28,代码来源:AddBootstrapFormAttributes.php

示例2: getHTML

 public function getHTML()
 {
     $this->checkForGetHTMLZendDependencies();
     $html = null;
     $renderer = new PhpRenderer();
     $formHelperConfig = new \Zend\Form\View\HelperConfig();
     $formHelperConfig->configureServiceManager($renderer->getHelperPluginManager());
     $formRenderer = new \Zend\Form\View\Helper\Form();
     $html .= $formRenderer->openTag($this->form);
     $formRow = new \Zend\Form\View\Helper\FormRow();
     $formRow->setView($renderer);
     foreach ($this->form->getElements() as $key => $element) {
         $html .= '<div id="' . $key . '" class="element">';
         $html .= $formRow->render($element);
         $html .= '</div>' . PHP_EOL;
     }
     $html .= $formRenderer->closeTag();
     return $html;
 }
开发者ID:caseypage,项目名称:php-ssrs-1,代码行数:19,代码来源:ZendFramework2.php

示例3: getPreparedFormData

 protected function getPreparedFormData(Form $form)
 {
     $formData = $form->getData();
     foreach ($form->getElements() as $element) {
         if ($element instanceof File) {
             if ($formData[$element->getName()]['size'] == 0) {
                 unset($formData[$element->getName()]);
             } else {
                 $formData[$element->getName()] = $formData[$element->getName()]['tmp_name'];
             }
         }
     }
     unset($formData['save']);
     return $formData;
 }
开发者ID:zend-bricks,项目名称:bricks-user,代码行数:15,代码来源:ProfileController.php

示例4: adjustOfSpecialElements

 /**
  * Ajusta os elementos especiais do formulário,
  * como por exemplo os campos de tipo select, que
  * deverão listar todos os registros de uma entidade
  * por padrão.
  * 
  * @param \Zend\Form\Form $form
  */
 public function adjustOfSpecialElements(Form $form)
 {
     foreach ($form->getElements() as $element) {
         if ($element instanceof Select && $this->elementMustBePopulated($element)) {
             // Obtém os registros de listagens padrões, a partir da entidade definida para o campo.
             $results = $this->getListValuesToSelectElement($element);
             $listValues = array($element->getEmptyOption() => self::STR_NENHUM_REGISTRO);
             $element->setEmptyOption(null);
             foreach ($results as $result) {
                 $title = !empty($result['title']) ? $result['title'] : $result['nome'];
                 $listValues[$result['id']] = $title;
             }
             $form->get($element->getAttribute('name'))->setValueOptions($listValues);
         }
     }
 }
开发者ID:augustoalvess,项目名称:dataware,代码行数:24,代码来源:Controller.php

示例5: parseFormMessage

 /**
  * @param \Zend\Form\Form $form
  * @return bool|string
  */
 private function parseFormMessage($form)
 {
     if (is_array($form->getMessages())) {
         $errorMessage = '';
         foreach ($form->getMessages() as $title => $values) {
             $formElement = $form->getElements();
             $errorMessage .= $formElement[$title]->getLabel() . PHP_EOL;
             if (is_array($values)) {
                 foreach ($values as $value) {
                     $errorMessage .= '<li>' . $value . '</li>';
                 }
             } else {
                 $errorMessage .= $values;
             }
         }
         return $errorMessage;
     } elseif (is_string($form->getMessages())) {
         return $form->getMessages();
     } else {
         return false;
     }
 }
开发者ID:arbi,项目名称:MyCode,代码行数:26,代码来源:General.php

示例6: getElements

 /**
  * @return array|\Traversable|Element[]
  */
 public function getElements()
 {
     return parent::getElements();
 }
开发者ID:siad007,项目名称:ctrllib,代码行数:7,代码来源:Form.php

示例7: resetForm

 /**
  * Resetting the values of the form passed. Unfortunately there is  no other way
  * in ZF2 to achieve this.
  *
  * @param Form $form Zend form to be reset
  *
  * @return void
  */
 protected function resetForm(Form $form)
 {
     $resetTypes = ['text', 'radio', 'email', 'textarea'];
     /**
      * Form element
      *
      * @var Element $element
      */
     foreach ($form->getElements() as $element) {
         if (in_array($element->getAttribute('type'), $resetTypes)) {
             $element->setValue('');
         }
     }
 }
开发者ID:guenterh,项目名称:vufind,代码行数:22,代码来源:FeedbackController.php


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