Fix FormValidator use addSelect instead of addElement('select'

pull/3924/head
Julio Montoya 4 years ago
parent 6902e76b81
commit 53e9721a5a
  1. 2
      public/main/admin/configure_extensions.php
  2. 2
      public/main/admin/export_certificates.php
  3. 2
      public/main/admin/extra_field_workflow.php
  4. 2
      public/main/admin/ldap_users_list.php
  5. 2
      public/main/admin/skills_profile.php
  6. 20
      public/main/admin/system_announcements.php
  7. 4
      public/main/admin/user_export.php
  8. 7
      public/main/admin/user_list.php
  9. 2
      public/main/announcements/announcements.php
  10. 2
      public/main/attendance/index.php
  11. 2
      public/main/coursecopy/copy_course.php
  12. 2
      public/main/document/create_audio.php
  13. 2
      public/main/dropbox/dropbox_functions.inc.php
  14. 2
      public/main/exercise/TestCategory.php
  15. 2
      public/main/exercise/question.class.php
  16. 2
      public/main/exercise/question_create.php
  17. 2
      public/main/extra/userInfo.php
  18. 2
      public/main/forum/forumfunction.inc.php
  19. 2
      public/main/group/group_creation.php
  20. 2
      public/main/group/settings.php
  21. 2
      public/main/inc/lib/career.lib.php
  22. 2
      public/main/inc/lib/document.lib.php
  23. 2
      public/main/inc/lib/extra_field_option.lib.php
  24. 2
      public/main/inc/lib/grade_model.lib.php
  25. 20
      public/main/inc/lib/pear/HTML/QuickForm.php
  26. 56
      public/main/inc/lib/pear/HTML/QuickForm/select.php
  27. 2
      public/main/inc/lib/promotion.lib.php
  28. 3
      public/main/inc/lib/sessionmanager.lib.php
  29. 2
      public/main/inc/lib/timeline.lib.php
  30. 2
      public/main/inc/lib/usergroup.lib.php
  31. 2
      public/main/lp/lp_edit.php
  32. 2
      public/main/mySpace/session_filter.php
  33. 2
      public/main/session/session_export.php
  34. 2
      public/main/survey/create_new_survey.php
  35. 2
      public/main/tracking/course_session_report.php
  36. 2
      public/main/tracking/exams.php
  37. 2
      public/main/tracking/lp_results_by_user.php
  38. 2
      public/main/upload/upload_ppt.php
  39. 2
      public/plugin/before_login/plugin.php
  40. 2
      public/plugin/hello_world/plugin.php
  41. 2
      public/plugin/vchamilo/plugin.php

@ -168,7 +168,7 @@ Display::display_header($nameTool);
$form->addElement('text', 'path_to_lzx', get_lang('Path to LZX files')); $form->addElement('text', 'path_to_lzx', get_lang('Path to LZX files'));
//$form -> addElement('html','<br /><br />'); //$form -> addElement('html','<br /><br />');
$options = ChamiloApi::getDocumentConversionSizes(); $options = ChamiloApi::getDocumentConversionSizes();
$form->addElement('select', 'size', get_lang('Size of the slides'), $options); $form->addSelect('size', get_lang('Size of the slides'), $options);
$form->addElement('hidden', 'extension_code', 'ppt2lp'); $form->addElement('hidden', 'extension_code', 'ppt2lp');
$defaults = []; $defaults = [];

@ -12,7 +12,7 @@ $options = [];
foreach ($courses as $course) { foreach ($courses as $course) {
$options[$course['id']] = $course['title']; $options[$course['id']] = $course['title'];
} }
$form->addElement('select', 'course', get_lang('Course'), $options); $form->addSelect('course', get_lang('Course'), $options);
$form->addElement('file', 'file', get_lang('File')); $form->addElement('file', 'file', get_lang('File'));
$form->addButton('submit', get_lang('Submit')); $form->addButton('submit', get_lang('Submit'));
$form->display(); $form->display();

@ -147,7 +147,7 @@ $options[STUDENT] = get_lang('Learner');
$options[COURSEMANAGER] = get_lang('Trainer'); $options[COURSEMANAGER] = get_lang('Trainer');
ksort($options); ksort($options);
$form->addElement('select', 'status', get_lang('Select role'), $options); $form->addSelect('status', get_lang('Select role'), $options);
$repo = $em->getRepository(ExtraFieldOptionRelFieldOption::class); $repo = $em->getRepository(ExtraFieldOptionRelFieldOption::class);

@ -155,7 +155,7 @@ $type["all"] = get_lang('All');
$type["employee"] = get_lang('Trainer'); $type["employee"] = get_lang('Trainer');
$type["student"] = get_lang('Learner'); $type["student"] = get_lang('Learner');
$form->addElement('select', 'keyword_type', get_lang('Status'), $type); $form->addSelect('keyword_type', get_lang('Status'), $type);
// Structure a rajouer ?? // Structure a rajouer ??
$form->addElement('submit', 'submit', get_lang('Validate')); $form->addElement('submit', 'submit', get_lang('Validate'));
//$defaults['keyword_active'] = 1; //$defaults['keyword_active'] = 1;

@ -24,7 +24,7 @@ $tpl = new Template(get_lang('Skills'));
$form = new FormValidator('profile_search'); $form = new FormValidator('profile_search');
$form->addElement('header', get_lang('Search skills')); $form->addElement('header', get_lang('Search skills'));
$form->addElement('select', 'skills', null, null, ['id' => 'skills']); $form->addSelect('skills', null, null, ['id' => 'skills']);
$form->addButtonSearch(get_lang('Search')); $form->addButtonSearch(get_lang('Search'));
$profiles = $skill_profile->get_all(); $profiles = $skill_profile->get_all();

@ -278,17 +278,6 @@ if ($action_todo) {
error_log($e); error_log($e);
} }
$group = [];
foreach ($visibleList as $key => $name) {
$group[] = $form->createElement(
'checkbox',
$key,
null,
$name
);
}
//$form->addGroup($group, null, get_lang('Visible'));
$form->addSelect('roles', get_lang('Visible'), $visibleList, ['multiple' => 'multiple']); $form->addSelect('roles', get_lang('Visible'), $visibleList, ['multiple' => 'multiple']);
$form->addElement('hidden', 'id'); $form->addElement('hidden', 'id');
@ -298,8 +287,7 @@ if ($action_todo) {
if (!empty($group_list)) { if (!empty($group_list)) {
$group_list = array_column($group_list, 'name', 'id'); $group_list = array_column($group_list, 'name', 'id');
$group_list[0] = get_lang('All'); $group_list[0] = get_lang('All');
$form->addElement( $form->addSelect(
'select',
'group', 'group',
get_lang('Announcement for a group'), get_lang('Announcement for a group'),
$group_list $group_list
@ -307,17 +295,17 @@ if ($action_todo) {
} }
$values['group'] = $values['group'] ?? '0'; $values['group'] = $values['group'] ?? '0';
$form->addElement('checkbox', 'send_mail', null, get_lang('Send mail')); $form->addCheckBox('send_mail', null, get_lang('Send mail'));
if ('add' === $action) { if ('add' === $action) {
$form->addElement('checkbox', 'add_to_calendar', null, get_lang('Add to calendar')); $form->addElement('checkbox', 'add_to_calendar', null, get_lang('Add to calendar'));
$text = get_lang('Add news'); $text = get_lang('Add news');
$class = 'add'; $class = 'add';
$form->addElement('hidden', 'action', 'add'); $form->addHidden('action', 'add');
} elseif ('edit' === $action) { } elseif ('edit' === $action) {
$text = get_lang('Edit News'); $text = get_lang('Edit News');
$class = 'save'; $class = 'save';
$form->addElement('hidden', 'action', 'edit'); $form->addHidden('action', 'edit');
} }
$form->addElement('checkbox', 'send_email_test', null, get_lang('Send an email to myself for testing purposes.')); $form->addElement('checkbox', 'send_email_test', null, get_lang('Send an email to myself for testing purposes.'));
$form->addButtonSend($text, 'submit'); $form->addButtonSend($text, 'submit');

@ -59,8 +59,8 @@ $form->addCheckBox(
], ],
get_lang('Yes, add the headers') get_lang('Yes, add the headers')
); );
$form->addElement('select', 'course_code', get_lang('Only users from the course'), $courses); $form->addSelect('course_code', get_lang('Only users from the course'), $courses);
$form->addElement('select', 'course_session', get_lang('Only users from the courseSession'), $coursesSessions); $form->addSelect('course_session', get_lang('Only users from the courseSession'), $coursesSessions);
$form->addButtonExport(get_lang('Export')); $form->addButtonExport(get_lang('Export'));
$form->setDefaults(['file_type' => 'csv']); $form->setDefaults(['file_type' => 'csv']);

@ -1094,16 +1094,15 @@ $status_options[DRH] = get_lang('Human Resources Manager');
$status_options[SESSIONADMIN] = get_lang('Course sessionsAdmin'); $status_options[SESSIONADMIN] = get_lang('Course sessionsAdmin');
$status_options[PLATFORM_ADMIN] = get_lang('Administrator'); $status_options[PLATFORM_ADMIN] = get_lang('Administrator');
$form->addElement( $form->addSelect(
'select',
'keyword_status', 'keyword_status',
get_lang('Profile'), get_lang('Profile'),
$status_options $status_options
); );
$active_group = []; $active_group = [];
$active_group[] = $form->createElement('checkbox', 'keyword_active', '', get_lang('active')); $active_group[] = $form->createElement('checkbox', 'keyword_active', '', get_lang('Active'));
$active_group[] = $form->createElement('checkbox', 'keyword_inactive', '', get_lang('inactive')); $active_group[] = $form->createElement('checkbox', 'keyword_inactive', '', get_lang('Inactive'));
$form->addGroup($active_group, '', get_lang('activeAccount'), null, false); $form->addGroup($active_group, '', get_lang('activeAccount'), null, false);
$form->addElement('checkbox', 'check_easy_passwords', null, get_lang('Check passwords too easy to guess')); $form->addElement('checkbox', 'check_easy_passwords', null, get_lang('Check passwords too easy to guess'));
$data = $extraField->addElements($form, 0, [], true, false, $variablesToShow); $data = $extraField->addElements($form, 0, [], true, false, $variablesToShow);

@ -186,7 +186,7 @@ switch ($action) {
} }
} }
$users = []; $users = [];
$searchForm->addElement('select', 'user_id', get_lang('Users'), $userList); $searchForm->addSelect('user_id', get_lang('Users'), $userList);
$searchForm->addButtonSearch(get_lang('Search')); $searchForm->addButtonSearch(get_lang('Search'));
$filterData = []; $filterData = [];

@ -557,7 +557,7 @@ switch ($action) {
'weekly' => get_lang('Weekly'), 'weekly' => get_lang('Weekly'),
'monthlyByDate' => get_lang('Monthly, by date'), 'monthlyByDate' => get_lang('Monthly, by date'),
]; ];
$form->addElement('select', 'repeat_type', get_lang('Repeat type'), $a_repeat_type); $form->addSelect('repeat_type', get_lang('Repeat type'), $a_repeat_type);
$form->addDatePicker( $form->addDatePicker(
'end_date_time', 'end_date_time',

@ -108,7 +108,7 @@ if (Security::check_token('post') && (
'post', 'post',
api_get_path(WEB_CODE_PATH).'coursecopy/copy_course.php?'.api_get_cidreq() api_get_path(WEB_CODE_PATH).'coursecopy/copy_course.php?'.api_get_cidreq()
); );
$form->addElement('select', 'destination_course', get_lang('Select target course'), $courses); $form->addSelect('destination_course', get_lang('Select target course'), $courses);
$group = []; $group = [];
$group[] = $form->createElement('radio', 'copy_option', null, get_lang('Full copy'), 'full_copy'); $group[] = $form->createElement('radio', 'copy_option', null, get_lang('Full copy'), 'full_copy');

@ -227,7 +227,7 @@ if ('google' == $service) {
$form->addElement('hidden', 'text2voice_mode', 'google'); $form->addElement('hidden', 'text2voice_mode', 'google');
$form->addElement('hidden', 'id', $document_id); $form->addElement('hidden', 'id', $document_id);
$form->addElement('text', 'title', get_lang('Title')); $form->addElement('text', 'title', get_lang('Title'));
$form->addElement('select', 'lang', get_lang('Language'), $options); $form->addSelect('lang', get_lang('Language'), $options);
$form->addElement('textarea', 'text', get_lang('Enter the text you want to convert to an audio file'), ['id' => 'textarea_google']); $form->addElement('textarea', 'text', get_lang('Enter the text you want to convert to an audio file'), ['id' => 'textarea_google']);
$form->addButtonSave(get_lang('Save mp3')); $form->addButtonSave(get_lang('Save mp3'));
$defaults = []; $defaults = [];

@ -209,7 +209,7 @@ function display_move_form(
foreach ($target as $category) { foreach ($target as $category) {
$options[$category['cat_id']] = $category['cat_name']; $options[$category['cat_id']] = $category['cat_name'];
} }
$form->addElement('select', 'move_target', get_lang('Move file to'), $options); $form->addSelect('move_target', get_lang('Move file to'), $options);
$form->addButtonMove(get_lang('Move the file'), 'do_move'); $form->addButtonMove(get_lang('Move the file'), 'do_move');
$form->display(); $form->display();
} }

@ -938,7 +938,7 @@ class TestCategory
} }
$form->addElement('html', $script); $form->addElement('html', $script);
$form->addElement('select', 'parent_id', get_lang('Parent'), $category_parent_list, ['id' => 'parent_id']); $form->addSelect('parent_id', get_lang('Parent'), $category_parent_list, ['id' => 'parent_id']);
$form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"'); $form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"');
// setting the defaults // setting the defaults

@ -1336,7 +1336,7 @@ abstract class Question
} }
//Medias //Medias
//$course_medias = self::prepare_course_media_select(api_get_course_int_id()); //$course_medias = self::prepare_course_media_select(api_get_course_int_id());
//$form->addElement('select', 'parent_id', get_lang('Attach to media'), $course_medias); //$form->addSelect('parent_id', get_lang('Attach to media'), $course_medias);
} }
$form->addElement('html', '</div>'); $form->addElement('html', '</div>');

@ -56,7 +56,7 @@ $exercises['-'] = '-'.get_lang('Select exercise').'-';
while ($row = Database :: fetch_array($result)) { while ($row = Database :: fetch_array($result)) {
$exercises[$row['iid']] = cut($row['title'], EXERCISE_MAX_NAME_SIZE); $exercises[$row['iid']] = cut($row['title'], EXERCISE_MAX_NAME_SIZE);
} }
$form->addElement('select', 'exercise', get_lang('Test'), $exercises); $form->addSelect('exercise', get_lang('Test'), $exercises);
// generate default content // generate default content
$form->addElement( $form->addElement(

@ -210,7 +210,7 @@ if ("viewDefEdit" == $displayMode) {
$possible_line_nrs[5] = '5 '.get_lang('lines'); $possible_line_nrs[5] = '5 '.get_lang('lines');
$possible_line_nrs[10] = '10 '.get_lang('lines'); $possible_line_nrs[10] = '10 '.get_lang('lines');
$possible_line_nrs[15] = '15 '.get_lang('lines'); $possible_line_nrs[15] = '15 '.get_lang('lines');
$edit_heading_form->addElement('select', 'nbline', get_lang('Line Number'), $possible_line_nrs); $edit_heading_form->addSelect('nbline', get_lang('Line Number'), $possible_line_nrs);
$edit_heading_form->addElement('submit', 'submitDef', get_lang('Validate')); $edit_heading_form->addElement('submit', 'submitDef', get_lang('Validate'));
$edit_heading_form->setDefaults($catToEdit); $edit_heading_form->setDefaults($catToEdit);
$edit_heading_form->display(); $edit_heading_form->display();

@ -4231,7 +4231,7 @@ function move_post_form()
foreach ($threads as $thread) { foreach ($threads as $thread) {
$threads_list[$thread->getIid()] = $thread->getThreadTitle(); $threads_list[$thread->getIid()] = $thread->getThreadTitle();
} }
$form->addElement('select', 'thread', get_lang('Move toThread'), $threads_list); $form->addSelect('thread', get_lang('Move toThread'), $threads_list);
$form->applyFilter('thread', 'html_filter'); $form->applyFilter('thread', 'html_filter');
// The OK button // The OK button

@ -327,7 +327,7 @@ EOT;
$classForm->addHtml($description); $classForm->addHtml($description);
$classForm->addElement('hidden', 'action'); $classForm->addElement('hidden', 'action');
if ($allowGroupCategories) { if ($allowGroupCategories) {
$classForm->addElement('select', 'group_category', null, $categories); $classForm->addSelect('group_category', null, $categories);
} else { } else {
$classForm->addElement('hidden', 'group_category'); $classForm->addElement('hidden', 'group_category');
} }

@ -60,7 +60,7 @@ if ('true' === api_get_setting('allow_group_categories')) {
foreach ($groupCategories as $category) { foreach ($groupCategories as $category) {
$categoryList[$category['iid']] = $category['title']; $categoryList[$category['iid']] = $category['title'];
} }
$form->addElement('select', 'category_id', get_lang('Category'), $categoryList); $form->addSelect('category_id', get_lang('Category'), $categoryList);
} else { } else {
$form->addHidden('category_id', 0); $form->addHidden('category_id', 0);
} }

@ -138,7 +138,7 @@ class Career extends Model
] ]
); );
$status_list = $this->get_status_list(); $status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list); $form->addSelect('status', get_lang('Status'), $status_list);
if ('edit' === $action) { if ('edit' === $action) {
$extraField = new ExtraField('career'); $extraField = new ExtraField('career');

@ -5328,7 +5328,7 @@ This folder contains all sessions that have been opened in the chat. Although th
} }
} }
} }
$form->addElement('select', 'move_to', get_lang('Move to'), $options); $form->addSelect('move_to', get_lang('Move to'), $options);
$form->addButtonNext(get_lang('Move element'), 'move_file_submit'); $form->addButtonNext(get_lang('Move element'), 'move_file_submit');
return $form->returnForm(); return $form->returnForm();

@ -770,7 +770,7 @@ class ExtraFieldOption extends Model
$form->addElement('text', 'option_value', get_lang('Value')); $form->addElement('text', 'option_value', get_lang('Value'));
$form->addElement('text', 'option_order', get_lang('Order')); $form->addElement('text', 'option_order', get_lang('Order'));
$form->addElement('select', 'priority', get_lang('Priority'), $this->getPriorityOptions()); $form->addSelect('priority', get_lang('Priority'), $this->getPriorityOptions());
$form->addElement('textarea', 'priority_message', get_lang('Message type')); $form->addElement('textarea', 'priority_message', get_lang('Message type'));
$defaults = []; $defaults = [];

@ -282,7 +282,7 @@ class GradeModel extends Model
$grade_model_options[$item['id']] = $item['name']; $grade_model_options[$item['id']] = $item['name'];
} }
} }
$form->addElement('select', $name, get_lang('Grading model'), $grade_model_options); $form->addSelect( $name, get_lang('Grading model'), $grade_model_options);
$default_platform_setting = api_get_setting('gradebook_default_grade_model_id'); $default_platform_setting = api_get_setting('gradebook_default_grade_model_id');
$default = -1; $default = -1;

@ -219,13 +219,14 @@ class HTML_QuickForm extends HTML_Common
if (isset($attributes['id']) && !empty($attributes['id'])) { if (isset($attributes['id']) && !empty($attributes['id'])) {
$form_id = Security::remove_XSS($attributes['id']); $form_id = Security::remove_XSS($attributes['id']);
} }
$attributes = array( $attributes = [
'action' => $action, 'action' => $action,
'method' => $method, 'method' => $method,
'name' => $formName, 'name' => $formName,
'id' => $form_id, 'id' => $form_id,
) + $target; ] + $target;
$this->updateAttributes($attributes); $this->updateAttributes($attributes);
//var_dump($_REQUEST);exit;
if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) { if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
$this->_submitValues = 'get' === $method ? $_GET : $_POST; $this->_submitValues = 'get' === $method ? $_GET : $_POST;
$this->_submitFiles = $_FILES; $this->_submitFiles = $_FILES;
@ -830,21 +831,6 @@ class HTML_QuickForm extends HTML_Common
if (isset($this->_submitValues[$base])) { if (isset($this->_submitValues[$base])) {
$value = isset($this->_submitValues[$base][$cleanId]) ? $this->_submitValues[$base][$cleanId] : null; $value = isset($this->_submitValues[$base][$cleanId]) ? $this->_submitValues[$base][$cleanId] : null;
} }
/*if ((is_array($value) || null === $value) && isset($this->_submitFiles[$base])) {
$props = array('name', 'type', 'size', 'tmp_name', 'error');
$code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" .
" return null;\n" .
"} else {\n" .
" \$v = array();\n";
foreach ($props as $prop) {
$code .= " \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n";
}
$fileValue = eval($code . " return \$v;\n}\n");
if (null !== $fileValue) {
$value = null === $value? $fileValue: HTML_QuickForm::arrayMerge($value, $fileValue);
}
}*/
} }
// This is only supposed to work for groups with appendName = false // This is only supposed to work for groups with appendName = false

@ -25,8 +25,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* Contains the select options * Contains the select options
* *
* @var array * @var array
* @since 1.0
* @access private
*/ */
protected $_options = []; protected $_options = [];
private $_optgroups = []; private $_optgroups = [];
@ -35,8 +33,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* Default values of the SELECT * Default values of the SELECT
* *
* @var array * @var array
* @since 1.0
* @access private
*/ */
protected $_values = []; protected $_values = [];
@ -54,37 +50,36 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
$elementName, $elementName,
$elementLabel = '', $elementLabel = '',
$options = null, $options = null,
$attributes = null array $attributes = []
) { ) {
$addBlank = ''; $addBlank = '';
if (is_array($attributes) || empty($attributes)) {
if (empty($attributes)) {
$attributes = [];
}
//selectpicker
$layout = $this->getLayout(); $layout = $this->getLayout();
if (FormValidator::LAYOUT_HORIZONTAL === $layout) { if (FormValidator::LAYOUT_HORIZONTAL === $layout) {
$attributes['class'] = 'form-control mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-indigo-500 sm:text-sm'; $attributes['class'] = 'form-control mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-indigo-500 sm:text-sm';
} }
$attributes['data-live-search'] = 'true';
//$attributes['data-live-search'] = 'true';
if (isset($attributes['disable_js']) && $attributes['disable_js']) { if (isset($attributes['disable_js']) && $attributes['disable_js']) {
$attributes['class'] = 'form-control'; //$attributes['class'] = 'form-control';
$attributes['data-live-search'] = ''; //$attributes['data-live-search'] = '';
} }
if (isset($attributes['extra_class']) && $attributes['extra_class']) { if (isset($attributes['extra_class']) && $attributes['extra_class']) {
$attributes['class'] .= ' '.$attributes['extra_class']; //$attributes['class'] .= ' '.$attributes['extra_class'];
unset($attributes['extra_class']); //unset($attributes['extra_class']);
} }
if (isset($attributes['placeholder'])) { if (isset($attributes['placeholder'])) {
$addBlank = $attributes['placeholder']; $addBlank = $attributes['placeholder'];
} }
if (isset($attributes['multiple'])) {
$attributes['class'] = 'overflow-auto w-full border bg-white rounded px-3 py-2 outline-none text-gray-700';
} }
$columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null;
$this->setColumnsSize($columnsSize);
//$columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null;
//$this->setColumnsSize($columnsSize);
parent::__construct($elementName, $elementLabel, $attributes); parent::__construct($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true; $this->_persistantFreeze = true;
$this->_type = 'select'; $this->_type = 'select';
@ -210,7 +205,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* Returns the element name * Returns the element name
* *
* @since 1.0 * @since 1.0
* @access public
* @return string * @return string
*/ */
public function getName() public function getName()
@ -222,7 +216,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* Returns the element name (possibly with brackets appended) * Returns the element name (possibly with brackets appended)
* *
* @since 1.0 * @since 1.0
* @access public
* @return string * @return string
*/ */
public function getPrivateName() public function getPrivateName()
@ -239,7 +232,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* *
* @param mixed $values Array or comma delimited string of selected values * @param mixed $values Array or comma delimited string of selected values
* @since 1.0 * @since 1.0
* @access public
* @return void * @return void
*/ */
public function setValue($value) public function setValue($value)
@ -251,7 +243,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* Returns an array of the selected values * Returns an array of the selected values
* *
* @since 1.0 * @since 1.0
* @access public
* @return array of selected values * @return array of selected values
*/ */
public function getValue() public function getValue()
@ -264,7 +255,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* *
* @param int $size Size of select field * @param int $size Size of select field
* @since 1.0 * @since 1.0
* @access public
* @return void * @return void
*/ */
public function setSize($size) public function setSize($size)
@ -276,7 +266,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* Returns the select field size * Returns the select field size
* *
* @since 1.0 * @since 1.0
* @access public
* @return int * @return int
*/ */
public function getSize() public function getSize()
@ -305,7 +294,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* Returns the select mutiple attribute * Returns the select mutiple attribute
* *
* @since 1.2 * @since 1.2
* @access public
* @return bool true if multiple select, false otherwise * @return bool true if multiple select, false otherwise
*/ */
public function getMultiple() public function getMultiple()
@ -321,30 +309,29 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* @param mixed $attributes Either a typical HTML attribute string * @param mixed $attributes Either a typical HTML attribute string
* or an associative array * or an associative array
* @since 1.0 * @since 1.0
* @access public
* @return void * @return void
*/ */
public function addOption($text, $value, $attributes = null, $return_array = false) public function addOption($text, $value, $attributes = null, $return_array = false)
{ {
if (null === $attributes) { if (null === $attributes) {
$attributes = array('value' => (string)$value); $attributes = ['value' => (string) $value];
} else { } else {
$attributes = $this->_parseAttributes($attributes); $attributes = $this->_parseAttributes($attributes);
if (isset($attributes['selected'])) { if (isset($attributes['selected'])) {
// the 'selected' attribute will be set in toHtml() // the 'selected' attribute will be set in toHtml()
$this->_removeAttr('selected', $attributes); $this->_removeAttr('selected', $attributes);
if (is_null($this->_values)) { if (is_null($this->_values)) {
$this->_values = array($value); $this->_values = [$value];
} elseif (!in_array($value, $this->_values)) { } elseif (!in_array($value, $this->_values)) {
$this->_values[] = $value; $this->_values[] = $value;
} }
} }
$this->_updateAttrArray($attributes, array('value' => (string)$value)); $this->_updateAttrArray($attributes, ['value' => (string) $value]);
} }
if ($return_array) { if ($return_array) {
return array('text' => $text, 'attr' => $attributes); return ['text' => $text, 'attr' => $attributes];
} else { } else {
$this->_options[] = array('text' => $text, 'attr' => $attributes); $this->_options[] = ['text' => $text, 'attr' => $attributes];
} }
} }
@ -356,7 +343,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* @param mixed $attributes Either a typical HTML attribute string * @param mixed $attributes Either a typical HTML attribute string
* or an associative array * or an associative array
* @since 1.0 * @since 1.0
* @access public
* @return void * @return void
*/ */
public function addOptGroup($options, $label) public function addOptGroup($options, $label)
@ -364,7 +350,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
foreach ($options as $option) { foreach ($options as $option) {
$this->addOption($option['text'], $option['value'], $option, true); $this->addOption($option['text'], $option['value'], $option, true);
} }
$this->_optgroups[] = array('label' => $label, 'options' => $options); $this->_optgroups[] = ['label' => $label, 'options' => $options];
} }
/** /**
@ -397,7 +383,8 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
if (!empty($strValues) && in_array($option['attr']['value'], $strValues, true)) { if (!empty($strValues) && in_array($option['attr']['value'], $strValues, true)) {
$option['attr']['selected'] = 'selected'; $option['attr']['selected'] = 'selected';
} }
$strHtml .= $tabs . "<option" . $this->_getAttrString($option['attr']) . '>' . $strHtml .=
$tabs."<option class='py-1' ".$this->_getAttrString($option['attr']).'>'.
$option['text']."</option>"; $option['text']."</option>";
} }
foreach ($this->_optgroups as $optgroup) { foreach ($this->_optgroups as $optgroup) {
@ -423,7 +410,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* Returns the value of field without HTML tags * Returns the value of field without HTML tags
* *
* @since 1.0 * @since 1.0
* @access public
* @return string * @return string
*/ */
public function getFrozenHtml() public function getFrozenHtml()

@ -258,7 +258,7 @@ class Promotion extends Model
['id' => 'career_id'] ['id' => 'career_id']
); );
$status_list = $this->get_status_list(); $status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list); $form->addSelect('status', get_lang('Status'), $status_list);
if ('edit' == $action) { if ('edit' == $action) {
$form->addElement('text', 'created_at', get_lang('Created at')); $form->addElement('text', 'created_at', get_lang('Created at'));
$form->freeze('created_at'); $form->freeze('created_at');

@ -7870,7 +7870,8 @@ class SessionManager
SESSION_VISIBLE_READ_ONLY => get_lang('Read only'), SESSION_VISIBLE_READ_ONLY => get_lang('Read only'),
SESSION_VISIBLE => get_lang('Accessible'), SESSION_VISIBLE => get_lang('Accessible'),
SESSION_INVISIBLE => api_ucfirst(get_lang('Not accessible')), SESSION_INVISIBLE => api_ucfirst(get_lang('Not accessible')),
] ],
[]
); );
$form->addGroup( $form->addGroup(
$visibilityGroup, $visibilityGroup,

@ -122,7 +122,7 @@ class Timeline extends Model
$form->addElement('text', 'headline', get_lang('Name'), ['size' => '70']); $form->addElement('text', 'headline', get_lang('Name'), ['size' => '70']);
$status_list = $this->get_status_list(); $status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list); $form->addSelect('status', get_lang('Status'), $status_list);
if ('edit' == $action) { if ('edit' == $action) {
//$form->addElement('text', 'created_at', get_lang('Created at')); //$form->addElement('text', 'created_at', get_lang('Created at'));
//$form->freeze('created_at'); //$form->freeze('created_at');

@ -1825,7 +1825,7 @@ class UserGroupModel extends Model
$form->addElement('checkbox', 'delete_picture', '', get_lang('Remove picture')); $form->addElement('checkbox', 'delete_picture', '', get_lang('Remove picture'));
} }
$form->addElement('select', 'visibility', get_lang('Group Permissions'), $this->getGroupStatusList()); $form->addSelect('visibility', get_lang('Group Permissions'), $this->getGroupStatusList());
$form->setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('Required field').'</small>'); $form->setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('Required field').'</small>');
$form->addElement('checkbox', 'allow_members_leave_group', '', get_lang('Allow members to leave group')); $form->addElement('checkbox', 'allow_members_leave_group', '', get_lang('Allow members to leave group'));

@ -89,7 +89,7 @@ $form->applyFilter('lp_name', 'html_filter');
$form->addRule('lp_name', get_lang('Required field'), 'required'); $form->addRule('lp_name', get_lang('Required field'), 'required');
$form->addElement('hidden', 'lp_encoding'); $form->addElement('hidden', 'lp_encoding');
$items = learnpath::getCategoryFromCourseIntoSelect(api_get_course_int_id(), true); $items = learnpath::getCategoryFromCourseIntoSelect(api_get_course_int_id(), true);
$form->addElement('select', 'category_id', get_lang('Category'), $items); $form->addSelect('category_id', get_lang('Category'), $items);
// Hide toc frame // Hide toc frame
$form->addElement( $form->addElement(

@ -66,7 +66,7 @@ foreach ($Sessions as $enreg) {
$options[$enreg['id']] = $enreg['name']; $options[$enreg['id']] = $enreg['name'];
} }
$form->addElement('select', 'session_id', get_lang('SessionList'), $options, ['id' => 'session-id']); $form->addSelect('session_id', get_lang('SessionList'), $options, ['id' => 'session-id']);
$form->addDatePicker('date_begin', get_lang('DateStart'), ['id' => 'date-begin']); $form->addDatePicker('date_begin', get_lang('DateStart'), ['id' => 'date-begin']);
$form->addDatePicker('date_end', get_lang('DateEnd'), ['id' => 'date-end']); $form->addDatePicker('date_end', get_lang('DateEnd'), ['id' => 'date-end']);

@ -306,7 +306,7 @@ foreach ($Sessions as $enreg) {
$options[$enreg['id']] = $enreg['name']; $options[$enreg['id']] = $enreg['name'];
} }
$form->addElement('select', 'session_id', get_lang('Choose the session to export'), $options); $form->addSelect('session_id', get_lang('Choose the session to export'), $options);
$form->addButtonExport(get_lang('Export session(s)')); $form->addButtonExport(get_lang('Export session(s)'));
$defaults = []; $defaults = [];

@ -167,7 +167,7 @@ $visibleResults = [
if (api_get_configuration_value('hide_survey_reporting_button')) { if (api_get_configuration_value('hide_survey_reporting_button')) {
$form->addLabel(get_lang('Results visibility'), get_lang('Feature disabled by administrator')); $form->addLabel(get_lang('Results visibility'), get_lang('Feature disabled by administrator'));
} else { } else {
$form->addElement('select', 'visible_results', get_lang('Results visibility'), $visibleResults); $form->addSelect('visible_results', get_lang('Results visibility'), $visibleResults);
} }
//$defaults['visible_results'] = 0; //$defaults['visible_results'] = 0;
$form->addElement( $form->addElement(

@ -39,7 +39,7 @@ foreach ($session_list as $sesion_item) {
if (0 == count($session_list)) { if (0 == count($session_list)) {
$my_session_list[0] = get_lang('none'); $my_session_list[0] = get_lang('none');
} }
$form->addElement('select', 'session_id', get_lang('Course sessions'), $my_session_list); $form->addSelect('session_id', get_lang('Course sessions'), $my_session_list);
$form->addButtonFilter(get_lang('Filter')); $form->addButtonFilter(get_lang('Filter'));
if (!empty($_REQUEST['score'])) { if (!empty($_REQUEST['score'])) {

@ -75,7 +75,7 @@ if ($global) {
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
$exerciseList[$row['id']] = $row['title']; $exerciseList[$row['id']] = $row['title'];
} }
$form->addElement('select', 'exercise_id', get_lang('Exercise'), $exerciseList); $form->addSelect('exercise_id', get_lang('Exercise'), $exerciseList);
} }
} }

@ -67,7 +67,7 @@ if ($global) {
while ($a_exercices = Database::fetch_array($resultExercices)) { while ($a_exercices = Database::fetch_array($resultExercices)) {
$exercise_list[$a_exercices['iid']] = $a_exercices['title']; $exercise_list[$a_exercices['iid']] = $a_exercices['title'];
} }
$form->addElement('select', 'exercise_id', get_lang('Test'), $exercise_list); $form->addSelect('exercise_id', get_lang('Test'), $exercise_list);
} }
//$form->addElement('submit','submit',get_lang('Filter')); //$form->addElement('submit','submit',get_lang('Filter'));

@ -84,7 +84,7 @@ $form->addElement('html', Display::return_message($message, 'info', false));
$form->addElement('file', 'user_file', [Display::return_icon('powerpoint_big.gif'), $div_upload_limit]); $form->addElement('file', 'user_file', [Display::return_icon('powerpoint_big.gif'), $div_upload_limit]);
$form->addElement('checkbox', 'take_slide_name', '', get_lang('Use the slides names as course learning object names')); $form->addElement('checkbox', 'take_slide_name', '', get_lang('Use the slides names as course learning object names'));
$options = ChamiloApi::getDocumentConversionSizes(); $options = ChamiloApi::getDocumentConversionSizes();
$form->addElement('select', 'slide_size', get_lang('Size of the slides'), $options); $form->addSelect('slide_size', get_lang('Size of the slides'), $options);
if ('true' === api_get_setting('search_enabled')) { if ('true' === api_get_setting('search_enabled')) {
$specific_fields = get_specific_field_list(); $specific_fields = get_specific_field_list();
$form->addElement('checkbox', 'index_document', '', get_lang('Index document text?ument')); $form->addElement('checkbox', 'index_document', '', get_lang('Index document text?ument'));

@ -20,7 +20,7 @@ $plugin_info['author'] = 'Julio Montoya';
// The plugin configuration. // The plugin configuration.
$form = new FormValidator('form'); $form = new FormValidator('form');
$form->addElement('select', 'language', get_lang('Language'), api_get_languages_to_array()); $form->addSelect('language', get_lang('Language'), api_get_languages_to_array());
$form->addElement('header', 'Option 1'); $form->addElement('header', 'Option 1');
$form->addElement('textarea', 'option1', get_lang('Description'), ['rows' => 10, 'class' => 'span6']); $form->addElement('textarea', 'option1', get_lang('Description'), ['rows' => 10, 'class' => 'span6']);

@ -33,7 +33,7 @@ $form = new FormValidator('hello_world_form');
//A simple select //A simple select
$options = ['hello_world' => 'Hello World', 'hello' => 'Hello', 'hi' => 'Hi!']; $options = ['hello_world' => 'Hello World', 'hello' => 'Hello', 'hi' => 'Hi!'];
$form->addElement('select', 'show_type', 'Hello world types', $options); $form->addSelect('show_type', 'Hello world types', $options);
$form->addButtonSave(get_lang('Save'), 'submit_button'); $form->addButtonSave(get_lang('Save'), 'submit_button');
$plugin_info['settings_form'] = $form; $plugin_info['settings_form'] = $form;

@ -62,7 +62,7 @@ $form->addLabel(
$plugin->get_lang('manage_instances').'</a>' $plugin->get_lang('manage_instances').'</a>'
); );
$form->addElement('header', $plugin->get_lang('enabling')); $form->addElement('header', $plugin->get_lang('enabling'));
$form->addElement('select', 'enable_virtualisation', $plugin->get_lang('enable_virtualisation'), $options); $form->addSelect('enable_virtualisation', $plugin->get_lang('enable_virtualisation'), $options);
$form->addElement( $form->addElement(
'text', 'text',
'course_real_root', 'course_real_root',

Loading…
Cancel
Save