本文整理汇总了PHP中FormValidator::addDateTimePicker方法的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator::addDateTimePicker方法的具体用法?PHP FormValidator::addDateTimePicker怎么用?PHP FormValidator::addDateTimePicker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormValidator
的用法示例。
在下文中一共展示了FormValidator::addDateTimePicker方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: intval
//.........这里部分代码省略.........
$field_details[3] = get_lang($field_details[3]);
}
$form->addElement('select', 'extra_' . $field_details[1], $field_details[3], $options, array('id' => 'extra_' . $field_details[1]));
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
$options = array();
foreach ($field_details[9] as $option_id => $option_details) {
$options[$option_details[1]] = $option_details[2];
}
$form->addElement('select', 'extra_' . $field_details[1], $field_details[3], $options, array('multiple' => 'multiple'));
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_DATE:
$form->addDatePicker('extra_' . $field_details[1], $field_details[3]);
$defaults['extra_' . $field_details[1]] = date('Y-m-d 12:00:00');
$form->setDefaults($defaults);
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
$form->applyFilter('theme', 'trim');
break;
case ExtraField::FIELD_TYPE_DATETIME:
$form->addDateTimePicker('extra_' . $field_details[1], $field_details[3]);
$defaults['extra_' . $field_details[1]] = date('Y-m-d 12:00:00');
$form->setDefaults($defaults);
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
$form->applyFilter('theme', 'trim');
break;
case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
foreach ($field_details[9] as $key => $element) {
if ($element[2][0] == '*') {
$values['*'][$element[0]] = str_replace('*', '', $element[2]);
} else {
$values[0][$element[0]] = $element[2];
}
}
$group = '';
$group[] = $form->createElement('select', 'extra_' . $field_details[1], '', $values[0], '');
$group[] = $form->createElement('select', 'extra_' . $field_details[1] . '*', '', $values['*'], '');
$form->addGroup($group, 'extra_' . $field_details[1], $field_details[3], ' ');
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
/* Recoding the selected values for double : if the user has
selected certain values, we have to assign them to the
correct select form */
if (array_key_exists('extra_' . $field_details[1], $extra_data)) {
// exploding all the selected values (of both select forms)
$selected_values = explode(';', $extra_data['extra_' . $field_details[1]]);
示例2: 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];
}
示例3: set_extra_fields_in_form
//.........这里部分代码省略.........
$form->addElement('label', null, $html.$table->toHtml());
}
}
}
*/
if (!$admin_permissions) {
if ($field_details['visible'] == 0) {
$form->freeze('extra_' . $field_details['variable']);
}
}
break;
case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
$options = array();
foreach ($field_details['options'] as $option_id => $option_details) {
$options[$option_details['option_value']] = $option_details['display_text'];
}
$form->addElement('select', 'extra_' . $field_details['variable'], $field_details['display_text'], $options, array('multiple' => 'multiple'));
if (!$admin_permissions) {
if ($field_details['visible'] == 0) {
$form->freeze('extra_' . $field_details['variable']);
}
}
break;
case ExtraField::FIELD_TYPE_DATE:
$form->addDatePicker('extra_' . $field_details['variable'], $field_details['display_text']);
if (!$admin_permissions) {
if ($field_details['visible'] == 0) {
$form->freeze('extra_' . $field_details['variable']);
}
}
$form->applyFilter('theme', 'trim');
break;
case ExtraField::FIELD_TYPE_DATETIME:
$form->addDateTimePicker('extra_' . $field_details['variable'], $field_details['display_text']);
$defaults['extra_' . $field_details['variable']] = api_get_local_time();
if (!isset($form->_defaultValues['extra_' . $field_details['variable']])) {
$form->setDefaults($defaults);
}
if (!$admin_permissions) {
if ($field_details['visible'] == 0) {
$form->freeze('extra_' . $field_details['variable']);
}
}
$form->applyFilter('theme', 'trim');
break;
case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
$first_select_id = 'first_extra_' . $field_details['variable'];
$url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php?1=1';
$jquery_ready_content .= '
$("#' . $first_select_id . '").on("change", function() {
var id = $(this).val();
if (id) {
$.ajax({
url: "' . $url . '&a=get_second_select_options",
dataType: "json",
data: "type=' . $type . '&field_id=' . $field_details['id'] . '&option_value_id="+id,
success: function(data) {
$("#second_extra_' . $field_details['variable'] . '").empty();
$.each(data, function(index, value) {
$("#second_extra_' . $field_details['variable'] . '").append($("<option/>", {
value: index,
text: value
}));
});
},
});
示例4: array
// Calendar list
$groupList = GroupManager::get_group_list();
$groupIdList = array('--');
foreach ($groupList as $group) {
$groupIdList[$group['id']] = $group['name'];
}
echo Display::page_subheader(get_lang('CalendarList'));
echo '<ul class="list-group">';
if (!empty($attendance_calendar)) {
foreach ($attendance_calendar as $calendar) {
echo '<li class="list-group-item">';
if (isset($action) && $action == 'calendar_edit' && (isset($calendar_id) && $calendar_id == $calendar['id'])) {
// calendar edit form
echo '<div class="attendance-calendar-edit">';
$form = new FormValidator('attendance_calendar_edit', 'POST', 'index.php?action=calendar_edit&attendance_id=' . $attendance_id . '&calendar_id=' . $calendar_id . '&' . api_get_cidreq(), '');
$form->addDateTimePicker('date_time', array(get_lang('Date')), array('form_name' => 'attendance_calendar_edit'), 5);
$defaults['date_time'] = $calendar['date_time'];
$form->addButtonSave(get_lang('Save'));
$form->addButtonCancel(get_lang('Cancel'), 'cancel');
$form->setDefaults($defaults);
$form->display();
echo '</div>';
} else {
echo Display::return_icon('lp_calendar_event.png', get_lang('DateTime'), null, ICON_SIZE_MEDIUM) . ' ' . substr($calendar['date_time'], 0, strlen($calendar['date_time']) - 3) . ' ';
if (isset($calendar['groups']) && !empty($calendar['groups'])) {
foreach ($calendar['groups'] as $group) {
echo ' ' . Display::label($groupIdList[$group['group_id']]);
}
}
if (!$is_locked_attendance || api_is_platform_admin()) {
if (api_is_allowed_to_edit()) {