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


PHP FormBuilder::getArrayValue方法代码示例

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


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

示例1: createElementObject

 /**
  * Convert an array of details into a form element.
  * @param String $fieldName The name of the form element
  * @param Array $fieldDetails The list of details for the form element.
  */
 protected function createElementObject($fieldName, $fieldDetails)
 {
     // Extract fields
     $label = $this->formObj->getArrayValue($fieldDetails, 'label');
     $type = $this->formObj->getArrayValue($fieldDetails, 'type');
     // Required 'true' or true are valid
     $required = $this->formObj->getArrayValue($fieldDetails, 'required');
     $required = $required == 'true' || $required == '1';
     // Start creating form element if anything other than a break.
     $elem = false;
     if ($type != 'break') {
         $elem = new FormElement($fieldName, $label, $required);
     }
     // Handle specific types
     switch ($type) {
         // Text Area
         case 'textarea':
             $rows = $this->formObj->getArrayValue($fieldDetails, 'rows') + 0;
             if ($rows == 0) {
                 $rows = 5;
             }
             $elem->setTypeAsTextArea($rows, 70);
             break;
             // Select/Dropdown
         // Select/Dropdown
         case 'select':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsComboBox($options);
             break;
             // Radio Buttons
         // Radio Buttons
         case 'radio':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsRadioButtons($options);
             break;
             // Checkbox
         // Checkbox
         case 'checkbox':
             $label = false;
             if (isset($fieldDetails['extralabel'])) {
                 $label = $fieldDetails['extralabel'];
             }
             $elem->setTypeAsCheckbox($label);
             break;
             // Checkbox List
         // Checkbox List
         case 'checkboxlist':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsCheckboxList($options);
             break;
             // Merged Fields - process each sub element
         // Merged Fields - process each sub element
         case 'merge':
             $elementList = array();
             if (!empty($fieldDetails['merge'])) {
                 foreach ($fieldDetails['merge'] as $fieldName => $fieldDetails) {
                     $elementList[] = $this->createElementObject($fieldName, $fieldDetails);
                 }
             }
             $elem->setTypeAsMergedElements($elementList);
             break;
             // File upload
         // File upload
         case 'uploadfile':
             $elem->setTypeAsUploadFile($this->formObj->getArrayValue($fieldDetails, 'show_existing'), $this->formObj->getArrayValue($fieldDetails, 'valid_if_value'));
             break;
             // Custom HTML
         // Custom HTML
         case 'custom':
             $elem->setTypeAsCustom($this->formObj->getArrayValue($fieldDetails, 'html'));
             break;
             // Hidden field
         // Hidden field
         case 'hidden':
             $elem->setTypeAsHidden();
             break;
             // Section break
         // Section break
         case 'break':
             $this->formObj->addBreak($fieldName, $this->formObj->getArrayValue($fieldDetails, 'html'));
             break;
             // Text box
         // Text box
         default:
             break;
     }
//.........这里部分代码省略.........
开发者ID:NClaus,项目名称:Ambrose,代码行数:101,代码来源:utils_easyform.inc.php

示例2: createElementObject

 /**
  * Convert an array of details into a form element.
  * @param String $fieldName The name of the form element
  * @param Array $fieldDetails The list of details for the form element.
  */
 protected function createElementObject($fieldName, $fieldDetails)
 {
     // Extract fields
     $label = $this->formObj->getArrayValue($fieldDetails, 'label');
     $type = $this->formObj->getArrayValue($fieldDetails, 'type');
     // Required 'true' or true are valid
     $required = $this->formObj->getArrayValue($fieldDetails, 'required');
     $required = $required == 'true' || $required == '1';
     // Start creating form element if anything other than a break.
     $elem = false;
     if ($type != 'break') {
         $elem = new FormElement($fieldName, $label, $required);
     }
     // Handle specific types
     switch ($type) {
         // Text Area
         case 'textarea':
             $rows = $this->formObj->getArrayValue($fieldDetails, 'rows') + 0;
             if ($rows == 0) {
                 $rows = 5;
             }
             $elem->setTypeAsTextArea($rows, 70);
             break;
             // Select/Dropdown
         // Select/Dropdown
         case 'select':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsComboBox($options);
             break;
             // Radio Buttons
         // Radio Buttons
         case 'radio':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsRadioButtons($options);
             break;
             // Checkbox
         // Checkbox
         case 'checkbox':
             $label = false;
             if (isset($fieldDetails['extralabel'])) {
                 $label = $fieldDetails['extralabel'];
             }
             $elem->setTypeAsCheckbox($label);
             break;
             // Checkbox List
         // Checkbox List
         case 'checkboxlist':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsCheckboxList($options);
             break;
             // Merged Fields - process each sub element
         // Merged Fields - process each sub element
         case 'merge':
             $elementList = array();
             if (!empty($fieldDetails['merge'])) {
                 foreach ($fieldDetails['merge'] as $fieldName => $fieldDetails) {
                     $elementList[] = $this->createElementObject($fieldName, $fieldDetails);
                 }
             }
             $elem->setTypeAsMergedElements($elementList);
             break;
             // Custom HTML
         // Custom HTML
         case 'custom':
             $elem->setTypeAsCustom($this->formObj->getArrayValue($fieldDetails, 'html'));
             break;
             // Hidden field
         // Hidden field
         case 'hidden':
             $elem->setTypeAsHidden();
             break;
             // Section break
         // Section break
         case 'break':
             $this->formObj->addBreak($fieldName, $this->formObj->getArrayValue($fieldDetails, 'html'));
             break;
             // Text box
         // Text box
         default:
             break;
     }
     // Add optional fields
     if ($type != 'break') {
         // Element description
         if ($desc = $this->formObj->getArrayValue($fieldDetails, 'desc')) {
             $elem->description = $desc;
//.........这里部分代码省略.........
开发者ID:nerdhaus,项目名称:avse,代码行数:101,代码来源:utils_easyform.inc.php


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