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


PHP FormBuilder::setDefaultValues方法代码示例

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


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

示例1: WPCW_showPage_ImportExport_export

/**
 * Show the export course page.
 */
function WPCW_showPage_ImportExport_export()
{
    $page = new PageBuilder(true);
    $page->showPageHeader(__('Export Training Course', 'wp_courseware'), '75%', WPCW_icon_getPageIconURL());
    // Show form of courses that can be exported.
    $form = new FormBuilder('wpcw_export');
    $form->setSubmitLabel(__('Export Course', 'wp_courseware'));
    // Course selection
    $formElem = new FormElement('export_course_id', __('Course to Export', 'wp_courseware'), true);
    $formElem->setTypeAsComboBox(WPCW_courses_getCourseList(__('--- Select a course to export ---', 'wp_courseware')));
    $form->addFormElement($formElem);
    // Options for what to export
    $formElem = new FormElement('what_to_export', __('What to Export', 'wp_courseware'), true);
    $formElem->setTypeAsRadioButtons(array('whole_course' => __('<b>All</b> - The whole course - including modules, units and quizzes.', 'wp_courseware'), 'just_course' => __('<b>Just the Course</b> - Just the course title, description and settings (no modules, units or quizzes).', 'wp_courseware'), 'course_modules' => __('<b>Course and Modules</b> - Just the course settings and module settings (no units or quizzes).', 'wp_courseware'), 'course_modules_and_units' => __('<b>Course, Modules and Units</b> - The course settings and module settings and units (no quizzes).', 'wp_courseware')));
    $form->addFormElement($formElem);
    $form->setDefaultValues(array('what_to_export' => 'whole_course'));
    if ($form->formSubmitted()) {
        // Do the full export
        if ($form->formValid()) {
            // If data is valid, export will be handled by export class.
        } else {
            $page->showListOfErrors($form->getListOfErrors(), __('Sorry, but unfortunately there were some errors. Please fix the errors and try again.', 'wp_courseware'));
        }
    }
    // Show selection menu for import/export to save pages
    WPCW_showPage_ImportExport_menu('export');
    printf('<p class="wpcw_doc_quick">');
    _e('When you export a course, you\'ll get an <b>XML file</b>, which you can then <b>import into another WordPress website</b> that\'s running <b>WP Courseware</b>.<br/> 
	    When you export the course units with a course, just the <b>HTML to render images and video</b> will be copied, but the <b>actual images and video files will not be exported</b>.', 'wp_courseware');
    printf('</p>');
    echo $form->toString();
    $page->showPageFooter();
}
开发者ID:umairriaz90,项目名称:Daschug1,代码行数:36,代码来源:page_import_export.inc.php

示例2: loadDefaults

 /**
  * Load the form object with the default values from an associative array mapping
  * field name => field value.
  * @param Array $valueList The list of values to load as defaults into the form.
  */
 public function loadDefaults($valueList)
 {
     if (!$valueList || !is_array($valueList)) {
         error_log('EasyForm:loadDefaults() - $valueList is empty');
         return;
     }
     // Filter the default values before they are loaded into the form.
     if ($this->filterBeforeLoadDefaultsFunction && function_exists($this->filterBeforeLoadDefaultsFunction)) {
         $valueList = call_user_func($this->filterBeforeLoadDefaultsFunction, $valueList);
     }
     $this->formObj->setDefaultValues($valueList);
 }
开发者ID:NClaus,项目名称:Ambrose,代码行数:17,代码来源:utils_easyform.inc.php

示例3: WPPortfolio_showSettingsPage


//.........这里部分代码省略.........
    _e("Change Cache Location", "wp-portfolio");
    ?>
</h2>
	<p><?php 
    echo __('You can either have the thumbnail cache stored in the <b>plugin directory</b> (which gets deleted when you upgrade the plugin), or you can have the thumbnail cache stored in the <b>wp-content directory</b> (which doesn\'t get deleted when you upgrade wp-portfolio). This is only useful if your thumbnails are set to never be updated and you don\'t want to lose the cached thumbnails.', 'wp-portfolio');
    ?>
</p>
	<dl>
		<dt><?php 
    _e('Plugin Location', 'wp-portfolio');
    ?>
: <?php 
    if (WPPortfolio_getCacheSetting() == 'plugin') {
        printf('&nbsp;&nbsp;<i class="wpp-cache-selected">(%s)</i>', __('Currently Selected', 'wp-portfolio'));
    }
    ?>
</dt>
		<dd><code><?php 
    echo WPPortfolio_getThumbPathURL('plugin');
    ?>
</code></dd>	
		
		<dt><?php 
    echo 'wp-content' . __(' Location', 'wp-portfolio');
    ?>
: <?php 
    if (WPPortfolio_getCacheSetting() == 'wpcontent') {
        printf('&nbsp;&nbsp;<i class="wpp-cache-selected">(%s)</i>', __('Currently Selected', 'wp-portfolio'));
    }
    ?>
</dt>
		<dd><code><?php 
    echo WPPortfolio_getThumbPathURL('wpcontent');
    ?>
</code></dd>
	</dl>
	
	<?php 
    $form = new FormBuilder('change_cache_location');
    // List of Cache Locations
    $cacheLocations = array('setting_cache_plugin' => __('Plugin Directory (Recommended)', 'wp-portfolio'), 'setting_cache_wpcontent' => __('wp-content Directory', 'wp-portfolio'));
    $formElem = new FormElement('new_cache_location', __('New Cache Location', 'wp-portfolio'));
    $formElem->setTypeAsComboBox($cacheLocations);
    $form->addFormElement($formElem);
    // Set the default location based on current setting.
    $form->setDefaultValues(array('new_cache_location' => get_option(WPP_CACHE_SETTING, true)));
    $form->setSubmitLabel(__('Change Cache Location', 'wp-portfolio'));
    echo $form->toString();
    ?>
	
	
	<p>&nbsp;</p>
	<hr>
	
	<h2><?php 
    _e("Upgrade Tables", "wp-portfolio");
    ?>
</h2>
	<p><?php 
    echo __("<p>If you're getting any errors relating to tables, you can force an upgrade of the database tables relating to WP Portfolio.", 'wp-portfolio');
    ?>
</p>
	<?php 
    $form = new FormBuilder('tables_force_upgrade');
    $form->setSubmitLabel(__('Force Table Upgrade', 'wp-portfolio'));
    echo $form->toString();
    ?>
	
	<hr>
	
	<h2><?php 
    _e("Upgrade Tables to UTF-8 Codepage (Advanced)", "wp-portfolio");
    ?>
</h2>
	<p><?php 
    echo __('As of V1.18, WP Portfolio uses UTF-8 as the default codepage for all text fields. Previously, for non Latin-based languages, the lack of UTF-8 support caused rendering issues with characters (such as using question marks and blocks for certain characters).', 'wp-portfolio');
    echo __('To upgrade to the new UTF-8 support, just click the button below. If you\'re <b>not experiencing problems</b> with website names and descriptions, then there\'s no need to click this button.</p>', 'wp-portfolio');
    ?>
	<?php 
    $form = new FormBuilder('codepage_upgrade');
    $form->setSubmitLabel(__('Upgrade Codepage to UTF-8', 'wp-portfolio'));
    echo $form->toString();
    ?>
		
		
		
	<hr>
	<h2><?php 
    _e('Uninstalling WP Portfolio', 'wp-portfolio');
    ?>
</h2>
	<p><?php 
    echo sprintf(__('If you\'re going to permanently uninstall WP Portfolio, you can also <a href="%s">remove all settings and data</a>.</p>', 'wp-portfolio'), 'admin.php?page=WPP_show_settings&uninstall=yes');
    ?>
		
	<p>&nbsp;</p>	
	<p>&nbsp;</p>
	</div>
	<?php 
}
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:wp-portfolio.php

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