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


PHP FormValidator::addCheckBox方法代码示例

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


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

示例1: setForm

 /**
  * @param FormValidator $form
  *
  * @return array
  */
 public static function setForm(FormValidator &$form, $sessionId = 0)
 {
     $categoriesList = SessionManager::get_all_session_category();
     $userInfo = api_get_user_info();
     $categoriesOptions = array('0' => get_lang('None'));
     if ($categoriesList != false) {
         foreach ($categoriesList as $categoryItem) {
             $categoriesOptions[$categoryItem['id']] = $categoryItem['name'];
         }
     }
     // Database Table Definitions
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $form->addElement('text', 'name', get_lang('SessionName'), array('maxlength' => 50));
     $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule('name', get_lang('SessionNameAlreadyExists'), 'callback', 'check_session_name');
     if (!api_is_platform_admin() && api_is_teacher()) {
         $form->addElement('select', 'coach_username', get_lang('CoachName'), [api_get_user_id() => $userInfo['complete_name']], array('id' => 'coach_username', 'class' => 'chzn-select', 'style' => 'width:370px;'));
     } else {
         $sql = "SELECT COUNT(1) FROM {$tbl_user} WHERE status = 1";
         $rs = Database::query($sql);
         $countUsers = Database::result($rs, 0, 0);
         if (intval($countUsers) < 50) {
             $orderClause = "ORDER BY ";
             $orderClause .= api_sort_by_first_name() ? "firstname, lastname, username" : "lastname, firstname, username";
             $sql = "SELECT user_id, lastname, firstname, username\n                        FROM {$tbl_user}\n                        WHERE status = '1' " . $orderClause;
             if (api_is_multiple_url_enabled()) {
                 $userRelAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
                 $accessUrlId = api_get_current_access_url_id();
                 if ($accessUrlId != -1) {
                     $sql = "SELECT user.user_id, username, lastname, firstname\n                        FROM {$tbl_user} user\n                        INNER JOIN {$userRelAccessUrlTable} url_user\n                        ON (url_user.user_id = user.user_id)\n                        WHERE\n                            access_url_id = {$accessUrlId} AND\n                            status = 1 " . $orderClause;
                 }
             }
             $result = Database::query($sql);
             $coachesList = Database::store_result($result);
             $coachesOptions = array();
             foreach ($coachesList as $coachItem) {
                 $coachesOptions[$coachItem['user_id']] = api_get_person_name($coachItem['firstname'], $coachItem['lastname']) . ' (' . $coachItem['username'] . ')';
             }
             $form->addElement('select', 'coach_username', get_lang('CoachName'), $coachesOptions);
         } else {
             $form->addElement('select_ajax', 'coach_username', get_lang('CoachName'), null, ['url' => api_get_path(WEB_AJAX_PATH) . 'session.ajax.php?a=search_general_coach', 'width' => '100%']);
         }
     }
     $form->addRule('coach_username', get_lang('ThisFieldIsRequired'), 'required');
     $form->addHtml('<div id="ajax_list_coachs"></div>');
     $form->addButtonAdvancedSettings('advanced_params');
     $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
     $form->addSelect('session_category', get_lang('SessionCategory'), $categoriesOptions, array('id' => 'session_category', 'class' => 'chzn-select', 'style' => 'width:370px;'));
     $form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Minimal'));
     $form->addElement('checkbox', 'show_description', null, get_lang('ShowDescription'));
     $visibilityGroup = array();
     $visibilityGroup[] = $form->createElement('select', 'session_visibility', null, array(SESSION_VISIBLE_READ_ONLY => get_lang('SessionReadOnly'), SESSION_VISIBLE => get_lang('SessionAccessible'), SESSION_INVISIBLE => api_ucfirst(get_lang('SessionNotAccessible'))));
     $form->addGroup($visibilityGroup, 'visibility_group', get_lang('SessionVisibility'), null, false);
     $options = [0 => get_lang('ByDuration'), 1 => get_lang('ByDates')];
     $form->addSelect('access', get_lang('Access'), $options, array('onchange' => 'accessSwitcher()', 'id' => 'access'));
     $form->addElement('html', '<div id="duration" style="display:none">');
     $form->addElement('number', 'duration', array(get_lang('SessionDurationTitle'), get_lang('SessionDurationDescription')), array('maxlength' => 50));
     $form->addElement('html', '</div>');
     $form->addElement('html', '<div id="date_fields" style="display:none">');
     // Dates
     $form->addDateTimePicker('access_start_date', array(get_lang('SessionStartDate'), get_lang('SessionStartDateComment')), array('id' => 'access_start_date'));
     $form->addDateTimePicker('access_end_date', array(get_lang('SessionEndDate'), get_lang('SessionEndDateComment')), array('id' => 'access_end_date'));
     $form->addRule(array('access_start_date', 'access_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty');
     $form->addDateTimePicker('display_start_date', array(get_lang('SessionDisplayStartDate'), get_lang('SessionDisplayStartDateComment')), array('id' => 'display_start_date'));
     $form->addDateTimePicker('display_end_date', array(get_lang('SessionDisplayEndDate'), get_lang('SessionDisplayEndDateComment')), array('id' => 'display_end_date'));
     $form->addRule(array('display_start_date', 'display_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty');
     $form->addDateTimePicker('coach_access_start_date', array(get_lang('SessionCoachStartDate'), get_lang('SessionCoachStartDateComment')), array('id' => 'coach_access_start_date'));
     $form->addDateTimePicker('coach_access_end_date', array(get_lang('SessionCoachEndDate'), get_lang('SessionCoachEndDateComment')), array('id' => 'coach_access_end_date'));
     $form->addRule(array('coach_access_start_date', 'coach_access_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty');
     $form->addElement('html', '</div>');
     $form->addCheckBox('send_subscription_notification', [get_lang('SendSubscriptionNotification'), get_lang('SendAnEmailWhenAUserBeingSubscribed')]);
     // Extra fields
     $extra_field = new ExtraField('session');
     $extra = $extra_field->addElements($form, $sessionId);
     $form->addElement('html', '</div>');
     $js = $extra['jquery_ready_content'];
     return ['js' => $js];
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:83,代码来源:sessionmanager.lib.php

示例2: getLinkForm

 /**
  * @param int $linkId
  * @param $action
  * @param null $urlview
  * @param null $token
  * @return FormValidator
  */
 public static function getLinkForm($linkId, $action, $token = null)
 {
     $course_id = api_get_course_int_id();
     $session_id = api_get_session_id();
     $linkInfo = Link::get_link_info($linkId);
     $categoryId = isset($linkInfo['category_id']) ? $linkInfo['category_id'] : '';
     $lpId = isset($_GET['lp_id']) ? Security::remove_XSS($_GET['lp_id']) : null;
     $category = 0;
     $form = new FormValidator('link', 'post', api_get_self() . '?action=' . $action . '&category_id=' . $categoryId . '&' . api_get_cidreq() . '&id=' . $linkId . '&sec_token=' . $token);
     if ($action == 'addlink') {
         $form->addHeader(get_lang('LinkAdd'));
     } else {
         $form->addHeader(get_lang('LinkMod'));
     }
     $target_link = "_blank";
     $title = '';
     $category = '';
     $onhomepage = '';
     $description = '';
     if (!empty($linkInfo)) {
         $urllink = $linkInfo['url'];
         $title = $linkInfo['title'];
         $description = $linkInfo['description'];
         $category = $linkInfo['category_id'];
         if ($linkInfo['on_homepage'] != 0) {
             $onhomepage = 1;
         }
         $target_link = $linkInfo['target'];
     }
     $form->addHidden('id', $linkId);
     $form->addText('url', 'URL');
     $form->addRule('url', get_lang('GiveURL'), 'url');
     $form->addText('title', get_lang('LinkName'));
     $form->addTextarea('description', get_lang('Description'));
     $resultcategories = Link::getLinkCategories($course_id, $session_id);
     $options = ['0' => '--'];
     if (!empty($resultcategories)) {
         foreach ($resultcategories as $myrow) {
             $options[$myrow['id']] = $myrow['category_title'];
         }
     }
     $form->addSelect('category_id', get_lang('Category'), $options);
     $form->addCheckBox('on_homepage', null, get_lang('OnHomepage'));
     $targets = array('_self' => get_lang('LinkOpenSelf'), '_blank' => get_lang('LinkOpenBlank'), '_parent' => get_lang('LinkOpenParent'), '_top' => get_lang('LinkOpenTop'));
     $form->addSelect('target', array(get_lang('LinkTarget'), get_lang('AddTargetOfLinkOnHomepage')), $targets);
     $defaults = array('url' => empty($urllink) ? 'http://' : Security::remove_XSS($urllink), 'title' => Security::remove_XSS($title), 'category_id' => $category, 'on_homepage' => $onhomepage, 'description' => $description, 'target' => $target_link);
     if (api_get_setting('search_enabled') == 'true') {
         require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
         $specific_fields = get_specific_field_list();
         $form->addCheckBox('index_document', get_lang('SearchFeatureDoIndexLink'), get_lang('Yes'));
         foreach ($specific_fields as $specific_field) {
             $default_values = '';
             if ($action == 'editlink') {
                 $filter = array('field_id' => $specific_field['id'], 'ref_id' => intval($_GET['id']), 'tool_id' => '\'' . TOOL_LINK . '\'');
                 $values = get_specific_field_values_list($filter, array('value'));
                 if (!empty($values)) {
                     $arr_str_values = array();
                     foreach ($values as $value) {
                         $arr_str_values[] = $value['value'];
                     }
                     $default_values = implode(', ', $arr_str_values);
                 }
             }
             $form->addText($specific_field['name'], $specific_field['code']);
             $defaults[$specific_field['name']] = $default_values;
         }
     }
     $form->addHidden('lp_id', $lpId);
     $form->addButtonSave(get_lang('SaveLink'), 'submitLink');
     $form->setDefaults($defaults);
     return $form;
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:79,代码来源:link.lib.php

示例3: createForm


//.........这里部分代码省略.........
                         $form->addElement('html','<div class="clear">&nbsp;</div>');
             
                         // add the radio display the category name for student
                         $radio_display_cat_name = array();
                         $radio_display_cat_name[] = $form->createElement('radio', 'display_category_name', null, get_lang('Yes'), '1');
                         $radio_display_cat_name[] = $form->createElement('radio', 'display_category_name', null, get_lang('No'), '0');
                             $form->addGroup($radio_display_cat_name, null, get_lang('QuestionDisplayCategoryName'), '');*/
         }
         // Attempts
         $attempt_option = range(0, 10);
         $attempt_option[0] = get_lang('Infinite');
         $form->addElement('select', 'exerciseAttempts', get_lang('ExerciseAttempts'), $attempt_option, ['id' => 'exerciseAttempts']);
         // Exercise time limit
         $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
         $var = Exercise::selectTimeLimit();
         if ($this->start_time != '0000-00-00 00:00:00') {
             $form->addElement('html', '<div id="start_date_div" style="display:block;">');
         } else {
             $form->addElement('html', '<div id="start_date_div" style="display:none;">');
         }
         $form->addElement('date_time_picker', 'start_time');
         $form->addElement('html', '</div>');
         $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
         if ($this->end_time != '0000-00-00 00:00:00') {
             $form->addElement('html', '<div id="end_date_div" style="display:block;">');
         } else {
             $form->addElement('html', '<div id="end_date_div" style="display:none;">');
         }
         $form->addElement('date_time_picker', 'end_time');
         $form->addElement('html', '</div>');
         //$check_option=$this->selectType();
         $diplay = 'block';
         $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults'));
         $form->addCheckBox('save_correct_answers', null, get_lang('Save the correct answers for the next attempt'));
         $form->addElement('html', '<div class="clear">&nbsp;</div>');
         $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
         $form->addElement('html', '<div id="divtimecontrol"  style="display:' . $diplay . ';">');
         //Timer control
         //$time_hours_option = range(0,12);
         //$time_minutes_option = range(0,59);
         $form->addElement('checkbox', 'enabletimercontrol', null, get_lang('EnableTimerControl'), array('onclick' => 'option_time_expired()', 'id' => 'enabletimercontrol', 'onload' => 'check_load_time()'));
         $expired_date = (int) $this->selectExpiredTime();
         if ($expired_date != '0') {
             $form->addElement('html', '<div id="timercontrol" style="display:block;">');
         } else {
             $form->addElement('html', '<div id="timercontrol" style="display:none;">');
         }
         $form->addText('enabletimercontroltotalminutes', get_lang('ExerciseTotalDurationInMinutes'), false, ['id' => 'enabletimercontroltotalminutes', 'cols-size' => [2, 2, 8]]);
         $form->addElement('html', '</div>');
         $form->addElement('text', 'pass_percentage', array(get_lang('PassPercentage'), null, '%'), array('id' => 'pass_percentage'));
         $form->addRule('pass_percentage', get_lang('Numeric'), 'numeric');
         // add the text_when_finished textbox
         $form->addHtmlEditor('text_when_finished', get_lang('TextWhenFinished'), false, false, $editor_config);
         $defaults = array();
         if (api_get_setting('search.search_enabled') === 'true') {
             require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
             $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
             $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
             $specific_fields = get_specific_field_list();
             foreach ($specific_fields as $specific_field) {
                 $form->addElement('text', $specific_field['code'], $specific_field['name']);
                 $filter = array('c_id' => api_get_course_int_id(), 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => "'" . TOOL_QUIZ . "'");
                 $values = get_specific_field_values_list($filter, array('value'));
                 if (!empty($values)) {
                     $arr_str_values = array();
                     foreach ($values as $value) {
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:67,代码来源:exercise.class.php

示例4: getWorkDescriptionToolbar

}
$form->addHtmlEditor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar());
$defaults['title'] = $work_item['title'];
$defaults["description"] = $work_item['description'];
$defaults['qualification'] = $work_item['qualification'];
if ($is_allowed_to_edit && !empty($item_id)) {
    // Get qualification from parent_id that will allow the validation qualification over
    $sql = "SELECT qualification FROM {$work_table}\n            WHERE c_id = {$course_id} AND id ='{$work_id}' ";
    $result = Database::query($sql);
    $row = Database::fetch_array($result);
    $qualification_over = $row['qualification'];
    if (!empty($qualification_over) && intval($qualification_over) > 0) {
        $form->addText('qualification', array(get_lang('Qualification'), " / " . $qualification_over), false, 'size="10"');
        $form->addElement('hidden', 'qualification_over', $qualification_over);
    }
    $form->addCheckBox('send_email', null, get_lang('SendMailToStudent'));
    // Check if user to qualify has some DRHs
    $drhList = UserManager::getDrhListFromUser($work_item['user_id']);
    if (!empty($drhList)) {
        $form->addCheckBox('send_to_drh_users', null, get_lang('SendMailToHR'));
    }
}
$form->addElement('hidden', 'active', 1);
$form->addElement('hidden', 'accepted', 1);
$form->addElement('hidden', 'item_to_edit', $item_id);
$form->addElement('hidden', 'sec_token', $token);
$text = get_lang('UpdateWork');
$class = 'save';
// fix the Ok button when we see the tool in the learn path
$form->addButtonUpdate($text);
$form->setDefaults($defaults);
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:edit.php

示例5: array

 $form->addHeader(get_lang('EditIcon'));
 $form->addHtml('<div class="col-md-7">');
 $form->addText('name', get_lang('Name'));
 $form->addText('link', get_lang('Links'));
 $allowed_picture_types = array('jpg', 'jpeg', 'png');
 $form->addFile('icon', get_lang('CustomIcon'));
 $form->addRule('icon', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
 $form->addSelect('target', get_lang('LinkTarget'), ['_self' => get_lang('LinkOpenSelf'), '_blank' => get_lang('LinkOpenBlank')]);
 $form->addSelect('visibility', get_lang('Visibility'), array(1 => get_lang('Visible'), 0 => get_lang('Invisible')));
 $form->addTextarea('description', get_lang('Description'), array('rows' => '3', 'cols' => '40'));
 $form->addButtonUpdate(get_lang('Update'));
 $form->addHtml('</div>');
 $form->addHtml('<div class="col-md-5">');
 if (isset($tool['custom_icon']) && !empty($tool['custom_icon'])) {
     $form->addLabel(get_lang('CurrentIcon'), Display::img(CourseHome::getCustomWebIconPath() . $tool['custom_icon']));
     $form->addCheckBox('delete_icon', null, get_lang('DeletePicture'));
 }
 $form->addHtml('</div>');
 $form->setDefaults($tool);
 $content = $form->returnForm();
 if ($form->validate()) {
     $data = $form->getSubmitValues();
     CourseHome::updateTool($id, $data);
     Display::addFlash(Display::return_message(get_lang('Updated')));
     if (isset($data['delete_icon'])) {
         CourseHome::deleteIcon($id);
     }
     $currentUrlReturn = api_get_self() . '?' . api_get_cidreq();
     header('Location: ' . $currentUrlReturn);
     exit;
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:tools.php

示例6: FormValidator

        $currencySelect->setSelected($currencyValue);
    }
}
$currencyForm->addButtonSave(get_lang('Save'));
$paypalForm = new FormValidator('paypal');
if ($paypalForm->validate()) {
    $paypalFormValues = $paypalForm->getSubmitValues();
    $plugin->savePaypalParams($paypalFormValues);
    Display::addFlash(Display::return_message(get_lang('Saved'), 'success'));
    header('Location:' . api_get_self());
    exit;
}
$paypalForm->addText('username', $plugin->get_lang('ApiUsername'), false, ['cols-size' => [3, 8, 1]]);
$paypalForm->addText('password', $plugin->get_lang('ApiPassword'), false, ['cols-size' => [3, 8, 1]]);
$paypalForm->addText('signature', $plugin->get_lang('ApiSignature'), false, ['cols-size' => [3, 8, 1]]);
$paypalForm->addCheckBox('sandbox', null, $plugin->get_lang('Sandbox'));
$paypalForm->addButtonSave(get_lang('Save'));
$paypalForm->setDefaults($plugin->getPaypalParams());
// Platform Commissions
$commissionForm = new FormValidator('commissions');
if ($commissionForm->validate()) {
    $commissionFormValues = $commissionForm->getSubmitValues();
    $plugin->updateCommission($commissionFormValues);
    Display::addFlash(Display::return_message(get_lang('Saved'), 'success'));
    header('Location:' . api_get_self());
    exit;
}
$commissionForm->addElement('number', 'commission', [$plugin->get_lang('Commission'), null, '%'], ['step' => 1, 'cols-size' => [3, 7, 1], 'min' => 0, 'max' => 100]);
$commissionForm->addButtonSave(get_lang('Save'));
$commissionForm->setDefaults($plugin->getPlatformCommission());
$transferForm = new FormValidator('transfer_account');
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:paymentsetup.php

示例7: FormValidator

            $defaultBeneficiaries[] = $courseCoach->getId();
        }
    }
    $currentBeneficiaries = $plugin->getItemBeneficiaries($sessionItem['item_id']);
    if (!empty($currentBeneficiaries)) {
        $defaultBeneficiaries = array_column($currentBeneficiaries, 'user_id');
    }
    $currencyIso = $sessionItem['currency'];
    $formDefaults = ['product_type' => get_lang('Session'), 'i' => $session->getId(), 't' => BuyCoursesPlugin::PRODUCT_TYPE_SESSION, 'name' => $sessionItem['session_name'], 'visible' => $sessionItem['visible'], 'price' => $sessionItem['price'], 'beneficiaries' => $defaultBeneficiaries];
} else {
    api_not_allowed(true);
}
$form = new FormValidator('beneficiaries');
$form->addText('product_type', $plugin->get_lang('ProductType'), false);
$form->addText('name', get_lang('Name'), false);
$visibleCheckbox = $form->addCheckBox('visible', $plugin->get_lang('VisibleInCatalog'), $plugin->get_lang('ShowOnCourseCatalog'));
$form->addElement('number', 'price', [$plugin->get_lang('Price'), null, $currencyIso], ['step' => 0.01]);
$beneficiariesSelect = $form->addSelect('beneficiaries', $plugin->get_lang('Beneficiaries'), null, ['multiple' => 'multiple']);
if ($editingCourse) {
    $beneficiariesSelect->addOptGroup($teachersOptions, get_lang('Teachers'));
} elseif ($editingSession) {
    $beneficiariesSelect->addOptGroup([$generalCoachOption], get_lang('SessionGeneralCoach'));
    $beneficiariesSelect->addOptGroup($courseCoachesOptions, get_lang('SessionCourseCoach'));
}
$form->addHidden('t', null);
$form->addHidden('i', null);
$form->addButtonSave(get_lang('Save'));
$form->freeze(['product_type', 'name']);
if ($form->validate()) {
    $formValues = $form->exportValues();
    $productItem = $plugin->getItemByProduct($formValues['i'], $formValues['t']);
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:configure_course.php


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