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


PHP FormBuilder::addFormElement方法代码示例

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


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

示例1: convertToFormObject

 /**
  * Convert the created details into a form object for use later.
  */
 protected function convertToFormObject()
 {
     if (empty($this->paramList)) {
         $this->formObj = false;
         return false;
     }
     $this->formObj = new FormBuilder($this->formID);
     // Start processing...
     foreach ($this->paramList as $fieldName => $fieldDetails) {
         $elem = $this->createElementObject($fieldName, $fieldDetails);
         // Finally add the form element
         $this->formObj->addFormElement($elem);
     }
 }
开发者ID:NClaus,项目名称:Ambrose,代码行数:17,代码来源:utils_easyform.inc.php

示例2: image

    /**
     * media library widget for image
     * @param $name
     * @param $data
     */
    protected function image($name, $data)
    {
        $c = $this->getFormElementPrototype($name, $data);
        $c->cssclass = 'media';
        $control = <<<EOF
<div class="media">
<input class="image_select" data-type="text" type="text" name="{$name}" />
<input class="image_button" type="button" name="select image" value="Select" />
</div>
EOF;
        $c->setTypeAsCustom($control);
        $this->form->addFormElement($c);
        $js = <<<EOF
jQuery(document).ready(function() {
\tvar currentTarget = null;

\tjQuery('.image_button').click(function() {
\tcurrentTarget = jQuery(this).prev('.image_select');
\ttb_show('', 'media-upload.php?type=image&TB_iframe=true');
\treturn false;
\t});

\twindow.send_to_editor = function(html) {
\timgurl = jQuery('<div>'+html+"</div>").find('img').attr('src');
\tcurrentTarget.val(imgurl);
\ttb_remove();
\t}

});
EOF;
        $this->form->addInlineJavascript($js);
        wp_enqueue_style('thickbox');
        wp_enqueue_script('media-upload');
        wp_enqueue_script('thickbox');
        wp_enqueue_script('jquery');
    }
开发者ID:clevervaughn,项目名称:dottiesbiscuitbarn,代码行数:41,代码来源:ctShortcodeDecorator.class.php

示例3: WPCW_showPage_ImportExport_importUsers

/**
 * Show the import course page.
 */
function WPCW_showPage_ImportExport_importUsers()
{
    $page = new PageBuilder(true);
    $page->showPageHeader(__('Import Users from CSV File', 'wp_courseware'), '75%', WPCW_icon_getPageIconURL());
    // Show selection menu for import/export to save pages
    WPCW_showPage_ImportExport_menu('import_users');
    // Show form to import some XML
    $form = new FormBuilder('wpcw_import_users');
    $form->setSubmitLabel(__('Import Users', 'wp_courseware'));
    // Course upload for XML file
    $formElem = new FormElement('import_course_csv', __('User Import CSV File', 'wp_courseware'), true);
    $formElem->setTypeAsUploadFile();
    $form->addFormElement($formElem);
    if ($form->formSubmitted()) {
        // Do the full export
        if ($form->formValid()) {
            // Handle the importing/uploading
            WPCW_users_importUsersFromFile($page);
        } else {
            $page->showListOfErrors($form->getListOfErrors(), __('Unfortunately, there were some errors trying to import the XML file.', 'wp_courseware'));
        }
    }
    // Workout maximum upload size
    $max_upload = (int) ini_get('upload_max_filesize');
    $max_post = (int) ini_get('post_max_size');
    $memory_limit = (int) ini_get('memory_limit');
    $upload_mb = min($max_upload, $max_post, $memory_limit);
    printf('<p class="wpcw_doc_quick">');
    printf(__('You can import a CSV file of users using the form below.', 'wp_courseware') . ' ' . __('The <b>maximum upload file size</b> for your server is <b>%d MB</b>.', 'wp_courseware'), $upload_mb);
    printf('</p>');
    echo $form->toString();
    printf('<br/><br/><div class="wpcw_docs_wrapper">');
    printf('<b>%s</b>', __('Some tips for importing users via a CSV file:', 'wp_courseware'));
    printf('<ul>');
    printf('<li>' . __('If a user email address already exists, then just the courses are updated for that user.', 'wp_courseware'));
    printf('<li>' . __('User names are generated from the first and last name information. If a user name already exists, then a unique username is generated.', 'wp_courseware'));
    printf('<li>' . __('To add a user to many courses, just separate those course IDs with a comma in the <code>courses_to_add_to</code> column.', 'wp_courseware'));
    printf('<li>' . __('If a user is created, any courses set to be automatically assigned will be done first, and then the courses added in the <code>courses_to_add_to</code> column.', 'wp_courseware'));
    printf('<li>' . __('You can download an <a href="%s">example CSV file here</a>.', 'wp_courseware') . '</li>', admin_url('?wpcw_export=csv_import_user_sample'));
    printf('<li>' . __('The IDs for the training courses can be found on the <a href="%s">course summary page</a>.', 'wp_courseware') . '</li>', admin_url('admin.php?page=WPCW_wp_courseware'));
    printf('</ul>');
    printf('</div>');
    $page->showPageFooter();
}
开发者ID:umairriaz90,项目名称:Daschug1,代码行数:47,代码来源:page_import_export.inc.php

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

示例5: showMembershipMappingLevels_specificLevel

 /**
  * Show the form for editing the specific courses a user can access based on what level that they have access to.
  * @param PageBuilder $page The page rendering object.
  * @param Array $levelDetails The list of level details
  */
 private function showMembershipMappingLevels_specificLevel($page, $levelDetails)
 {
     // Show a nice summary of what level is being edited.
     printf('<div id="wpcw_member_level_name_title">%s</div>', sprintf(__('Editing permissions for <b>%s</b> level with <b>%s</b>:', 'wp_courseware'), $levelDetails['name'], $this->extensionName));
     // Get a list of course IDs that exist
     $courses = WPCW_courses_getCourseList(false);
     // Get list of courses already associated with level.
     $courseListInDB = $this->getCourseAccessListForLevel($levelDetails['id']);
     // Create the summary URL to return
     $summaryURL = admin_url('admin.php?page=' . $this->extensionID);
     // Update form...
     $form = new FormBuilder('wpcw_member_levels_edit');
     $form->setSubmitLabel(__('Save Changes', 'wp_courseware'));
     // Create list of courses using checkboxes (max of 2 columns)
     $elem = new FormElement('level_courses', __('Courses user can access at this level', 'wp_courseware'), false);
     $elem->setTypeAsCheckboxList($courses);
     $elem->checkboxListCols = 2;
     $form->addFormElement($elem);
     // Normally would check for errors too, but there's not a lot to check here.
     if ($form->formSubmitted()) {
         if ($form->formValid()) {
             $mapplingList = $form->getValue('level_courses');
             global $wpdb, $wpcwdb;
             $wpdb->show_errors();
             // Remove all previous level mappings (as some will have been removed)
             $wpdb->query($wpdb->prepare("\n\t\t\t\t\t\tDELETE \n\t\t\t\t\t\tFROM {$wpcwdb->map_member_levels} \n\t\t\t\t\t\tWHERE member_level_id = %s\n\t\t\t\t\t", $levelDetails['id']));
             // Add all of the new mappings the user has chosen.
             if ($mapplingList && count($mapplingList) > 0) {
                 foreach ($mapplingList as $courseID => $itemState) {
                     $wpdb->query($wpdb->prepare("\n\t\t\t\t\t\t\t\tINSERT INTO {$wpcwdb->map_member_levels} \n\t\t\t\t\t\t\t\t(course_id, member_level_id)  \n\t\t\t\t\t\t\t\tVALUES (%d, %s)\n\t\t\t\t\t\t\t", $courseID, $levelDetails['id']));
                 }
             }
             // Show a success message.
             $page->showMessage(__('Level and course permissions successfully updated.', 'wp_courseware') . '<br/><br/>' . sprintf(__('Want to return to the <a href="%s">Course Access Settings summary</a>?', 'wp_courseware'), $summaryURL));
         }
         // if ($form->formValid())
     } else {
         $form->setDefaultValues(array('level_courses' => $courseListInDB));
     }
     // Show the form
     echo $form->toString();
     printf('<a href="%s" class="button-secondary">%s</a>', $summaryURL, __('&laquo; Return to Course Access Settings summary', 'wp_courseware'));
 }
开发者ID:JalpMi,项目名称:v2contact,代码行数:48,代码来源:class_members.inc.php


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