本文整理汇总了PHP中FormBuilder::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::getValue方法的具体用法?PHP FormBuilder::getValue怎么用?PHP FormBuilder::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::getValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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, __('« Return to Course Access Settings summary', 'wp_courseware'));
}
示例2: testGetValue
public function testGetValue()
{
$this->element->value('test');
$this->assertSame('test', $this->element->getValue());
}