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


PHP FormElement::setTypeAsHidden方法代码示例

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


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

示例1: __construct

 /**
  * Default constructor that takes in initial parameters.
  * @param Array $paramList The list of parameters to create the form from.
  * @param String $tableName The name of the table to save the details to (or retrieve them from).
  * @param String $primaryKey The name of the primary key used to locate a record to update it.
  * @param Stirng $metaTableName The name of the table storing meta data. 
  * @param String $formID The optional ID to give to the form. Ideal for when there's more than 1 form on a page. 
  */
 public function __construct($paramList, $tableName, $primaryKey, $metaTableName = false, $formID = false)
 {
     parent::__construct($paramList, $formID);
     // Default save text reflects this is a data entry form.
     $this->buttonText = 'Save Details';
     $this->tableName = $tableName;
     $this->primaryKey = $primaryKey;
     $this->primaryKeyValue = false;
     $this->fn_record_updated = false;
     $this->fn_record_created = false;
     // Exists checks
     $this->alreadyInDB = false;
     // Turn primary key into a hidden field, so that we can handle modifies.
     $elem = new FormElement($primaryKey, false);
     $elem->setTypeAsHidden();
     $this->formObj->addFormElement($elem);
     // Meta data support
     $this->metaTableName = $metaTableName;
     $this->meta_element_list = false;
     // Pull out fields being stored as meta data if we have a meta table name
     if ($metaTableName) {
         $this->meta_element_list = array();
         if (!empty($paramList)) {
             foreach ($paramList as $fieldName => $fieldDetails) {
                 // We're looking for metadata => true in the list of elements
                 // which determines it should be saved as meta data, not as a
                 // value in the normal table column.
                 if (isset($fieldDetails['metadata']) && $fieldDetails['metadata'] == true) {
                     $this->meta_element_list[] = $fieldName;
                 }
             }
             // end foreach
         }
         // end if (!empty($paramList))
     }
     // end if ($metaTableName)
     // Default messages
     $this->msg_record_created = 'Record successfully created';
     $this->msg_record_updated = 'Record successfully updated.';
 }
开发者ID:NClaus,项目名称:Ambrose,代码行数:48,代码来源:utils_recordsform.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;
             // 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

示例3: WPPortfolio_modify_group


//.........这里部分代码省略.........
    if ($editmode && $groupid == 0) {
        WPPortfolio_showMessage(sprintf(__('Sorry, but no group with that ID could be found. Please click <a href="%s">here</a> to return to the list of groups.', 'wp-portfolio'), WPP_GROUP_SUMMARY), true);
        return;
    }
    $groupdetails = false;
    // ### EDIT ### Check if we're adding or editing a group
    if ($editmode && $groupid > 0) {
        // Get details from the database
        $groupdetails = WPPortfolio_getGroupDetails($groupid);
        // False alarm, couldn't find it.
        if (count($groupdetails) == 0) {
            $editmode = false;
        }
    }
    // end of editing check
    // Check if group is being updated/added.
    if (isset($_POST) && isset($_POST['update'])) {
        // Grab specified details
        $data = array();
        $data['groupid'] = $groupid;
        $data['groupname'] = strip_tags($_POST['group_groupname']);
        $data['groupdescription'] = $_POST['group_groupdescription'];
        $data['grouporder'] = $_POST['group_grouporder'] + 0;
        // Add zero to convert to number
        // Keep track of errors for validation
        $errors = array();
        // Ensure all fields have been completed
        if (!($data['groupname'] && $data['groupdescription'])) {
            array_push($errors, __("Please check that you have completed the group name and description fields.", 'wp-portfolio'));
        }
        // Continue if there are no errors
        if (count($errors) == 0) {
            global $wpdb;
            $table_name = $wpdb->prefix . TABLE_WEBSITE_GROUPS;
            // Change query based on add or edit
            if ($editmode) {
                $query = arrayToSQLUpdate($table_name, $data, 'groupid');
            } else {
                unset($data['groupid']);
                // Don't need id for an insert
                $query = arrayToSQLInsert($table_name, $data);
            }
            // Try to put the data into the database
            $wpdb->show_errors();
            $wpdb->query($query);
            // When editing, show what we've just been editing.
            if ($editmode) {
                WPPortfolio_showMessage(__("Group details successfully updated.", 'wp-portfolio'));
                // Retrieve the details from the database again
                $groupdetails = WPPortfolio_getGroupDetails($groupid);
            } else {
                WPPortfolio_showMessage(__("Group details successfully added.", 'wp-portfolio'));
                $groupdetails['groupid'] = false;
                $groupdetails['groupname'] = false;
                $groupdetails['groupdescription'] = false;
                $groupdetails['grouporder'] = false;
            }
        } else {
            $message = __("Sorry, but unfortunately there were some errors. Please fix the errors and try again.", 'wp-portfolio') . '<br><br>';
            $message .= "<ul style=\"margin-left: 20px; list-style-type: square;\">";
            // Loop through all errors in the $error list
            foreach ($errors as $errormsg) {
                $message .= "<li>{$errormsg}</li>";
            }
            $message .= "</ul>";
            WPPortfolio_showMessage($message, true);
            $groupdetails = $data;
        }
    }
    $form = new FormBuilder();
    $formElem = new FormElement("group_groupname", __("Group Name", 'wp-portfolio'));
    $formElem->value = WPPortfolio_getArrayValue($groupdetails, 'groupname');
    $formElem->description = __("The name for this group of websites.", 'wp-portfolio');
    $form->addFormElement($formElem);
    $formElem = new FormElement("group_groupdescription", __("Group Description", 'wp-portfolio'));
    $formElem->value = WPPortfolio_getArrayValue($groupdetails, 'groupdescription');
    $formElem->description = __("The description of your group. HTML is permitted.", 'wp-portfolio');
    $formElem->setTypeAsTextArea(4, 70);
    $form->addFormElement($formElem);
    $formElem = new FormElement("group_grouporder", __("Group Order", 'wp-portfolio'));
    $formElem->value = WPPortfolio_getArrayValue($groupdetails, 'grouporder');
    $formElem->description = '&bull; ' . __("The number to use for ordering the groups. Groups are rendered in ascending order, first by this order value (lowest value first), then by group name.", 'wp-portfolio') . '<br/>' . '&bull; ' . __('e.g. Groups (A, B, C, D) with ordering (50, 100, 0, 50) will be rendered as (C, A, D, B).', 'wp-portfolio') . '<br/>' . '&bull; ' . __("If all groups have 0 for ordering, then the groups are rendered in alphabetical order.", 'wp-portfolio');
    $form->addFormElement($formElem);
    // Hidden Elements
    $formElem = new FormElement("group_groupid", false);
    $formElem->value = WPPortfolio_getArrayValue($groupdetails, 'groupid');
    $formElem->setTypeAsHidden();
    $form->addFormElement($formElem);
    $formElem = new FormElement("editmode", false);
    $formElem->value = $editmode ? "edit" : "add";
    $formElem->setTypeAsHidden();
    $form->addFormElement($formElem);
    $form->setSubmitLabel(($editmode ? __("Update", 'wp-portfolio') : __("Add", 'wp-portfolio')) . " " . __("Group Details", 'wp-portfolio'));
    echo $form->toString();
    ?>
		
	<br><br>
	</div><!-- wrap -->
	<?php 
}
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:wp-portfolio.php

示例4: 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


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