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


PHP HtmlElementFactory::getElementType方法代码示例

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


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

示例1: getFormHtml

 /**
  * Process and render the form with HTML output.
  *
  * @param bool $fieldsOnly
  * @return string html
  */
 public function getFormHtml($fieldsOnly = false)
 {
     // if no form was loaded return empty string
     if (empty($this->form)) {
         return '';
     }
     $fields_html = array();
     $view = new AView($this->registry, 0);
     foreach ($this->fields as $field) {
         $data = array('type' => HtmlElementFactory::getElementType($field['element_type']), 'name' => $field['field_name'], 'form' => $this->form['form_name'], 'attr' => $field['attributes'], 'required' => $field['required'], 'value' => $field['value'], 'options' => $field['options']);
         switch ($data['type']) {
             case 'multiselectbox':
                 $data['name'] .= '[]';
                 break;
             case 'checkboxgroup':
                 $data['name'] .= '[]';
                 break;
             case 'captcha':
                 $data['captcha_url'] = $this->html->getURL('common/captcha');
                 break;
         }
         $item = HtmlElementFactory::create($data);
         switch ($data['type']) {
             case 'IPaddress':
             case 'hidden':
                 $fields_html[$field['field_id']] = $item->getHtml();
                 break;
             default:
                 $view->batchAssign(array('element_id' => $item->element_id, 'title' => $field['name'], 'description' => !empty($this->form['description']) ? $field['description'] : '', 'error' => !empty($this->errors[$field['field_name']]) ? $this->errors[$field['field_name']] : '', 'item_html' => $item->getHtml()));
                 $fields_html[$field['field_id']] = $view->fetch('form/form_field.tpl');
         }
     }
     $output = '';
     if (!empty($this->groups)) {
         foreach ($this->groups as $group) {
             $view->batchAssign(array('group' => $group, 'fields_html' => $fields_html));
             $output .= $view->fetch('form/form_group.tpl');
         }
     } else {
         $view->batchAssign(array('fields_html' => $fields_html));
         $output .= $view->fetch('form/form_no_group.tpl');
     }
     // add submit button and form open/close tag
     if (!$fieldsOnly) {
         $data = array('type' => 'submit', 'form' => $this->form['form_name'], 'name' => $this->language->get('button_continue'), 'icon' => 'icon-arrow-right');
         $submit = HtmlElementFactory::create($data);
         $data = array('type' => 'form', 'name' => $this->form['form_name'], 'attr' => ' class="form" ', 'action' => $this->html->getSecureURL($this->form['controller'], '&form_id=' . $this->form['form_id'], true));
         $form_open = HtmlElementFactory::create($data);
         $form_close = $view->fetch('form/form_close.tpl');
         $js = $this->addFormJs();
         $view->batchAssign(array('description' => $this->form['description'], 'form' => $output, 'form_open' => $js . $form_open->getHtml(), 'form_close' => $form_close, 'submit' => $submit->getHtml()));
         $output = $view->fetch('form/form.tpl');
     }
     return $output;
 }
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:61,代码来源:form.php

示例2: getFormHtml

 /**
  * Process and render the form with HTML output.
  *
  * @param bool $fieldsOnly
  * @return string html
  */
 public function getFormHtml($fieldsOnly = false)
 {
     // if no form was loaded return empty string
     if (empty($this->form)) {
         return '';
     }
     $fields_html = array();
     $view = new AView($this->registry, 0);
     foreach ($this->fields as $field) {
         //check for enabled recaptcha instead of default captcha
         if ($this->config->get('config_recaptcha_site_key') && $field['element_type'] == 'K') {
             $field['element_type'] = 'J';
         }
         //build data array for each field HTML template
         $data = array('type' => HtmlElementFactory::getElementType($field['element_type']), 'name' => $field['field_name'], 'form' => $this->form['form_name'], 'attr' => $field['attributes'], 'required' => $field['required'], 'value' => $field['value'], 'options' => $field['options']);
         //populate customer entered values from session (if present)
         if (is_array($this->session->data['custom_form_' . $this->form['form_id']])) {
             $data['value'] = $this->session->data['custom_form_' . $this->form['form_id']][$field['field_name']];
         }
         //custom data based on the HTML element type
         switch ($data['type']) {
             case 'multiselectbox':
                 $data['name'] .= '[]';
                 break;
             case 'checkboxgroup':
                 $data['name'] .= '[]';
                 break;
             case 'captcha':
                 $data['captcha_url'] = $this->html->getURL('common/captcha');
                 break;
             case 'recaptcha':
                 $data['recaptcha_site_key'] = $this->config->get('config_recaptcha_site_key');
                 $data['language_code'] = $this->language->getLanguageCode();
                 break;
         }
         $item = HtmlElementFactory::create($data);
         switch ($data['type']) {
             case 'IPaddress':
             case 'hidden':
                 $fields_html[$field['field_id']] = $item->getHtml();
                 break;
             default:
                 $view->batchAssign(array('element_id' => $item->element_id, 'type' => $data['type'], 'title' => $field['name'], 'description' => !empty($field['description']) ? $field['description'] : '', 'error' => !empty($this->errors[$field['field_name']]) ? $this->errors[$field['field_name']] : '', 'item_html' => $item->getHtml()));
                 $fields_html[$field['field_id']] = $view->fetch('form/form_field.tpl');
         }
     }
     $output = '';
     if (!empty($this->groups)) {
         foreach ($this->groups as $group) {
             $view->batchAssign(array('group' => $group, 'fields_html' => $fields_html));
             $output .= $view->fetch('form/form_group.tpl');
         }
     } else {
         $view->batchAssign(array('fields_html' => $fields_html));
         $output .= $view->fetch('form/form_no_group.tpl');
     }
     // add submit button and form open/close tag
     if (!$fieldsOnly) {
         $data = array('type' => 'submit', 'form' => $this->form['form_name'], 'name' => $this->language->get('button_submit'));
         $submit = HtmlElementFactory::create($data);
         $data = array('type' => 'form', 'name' => $this->form['form_name'], 'attr' => ' class="form" ', 'action' => $this->html->getSecureURL($this->form['controller'], '&form_id=' . $this->form['form_id'], true));
         $form_open = HtmlElementFactory::create($data);
         $form_close = $view->fetch('form/form_close.tpl');
         $js = $this->addFormJs();
         $view->batchAssign(array('description' => $this->form['description'], 'form' => $output, 'form_open' => $js . $form_open->getHtml(), 'form_close' => $form_close, 'submit' => $submit));
         $output = $view->fetch('form/form.tpl');
     }
     return $output;
 }
开发者ID:InquisitiveQuail,项目名称:abantecart-src,代码行数:75,代码来源:form.php


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