diff --git a/public/main/admin/course_edit.php b/public/main/admin/course_edit.php index d7fd5e5d9d..046fe07403 100644 --- a/public/main/admin/course_edit.php +++ b/public/main/admin/course_edit.php @@ -509,7 +509,6 @@ function valide() { } "; -// Display the form $form->display(); -Display :: display_footer(); +Display::display_footer(); diff --git a/public/main/admin/index.php b/public/main/admin/index.php index 2f39114457..108976caeb 100644 --- a/public/main/admin/index.php +++ b/public/main/admin/index.php @@ -200,7 +200,7 @@ if (api_is_platform_admin()) { $searchForm = new FormValidator( 'search_session', 'GET', - api_get_path(WEB_CODE_PATH).'admin/session_list.php', + $sessionPath.'session_list.php', null, null, FormValidator::LAYOUT_BOX_SEARCH diff --git a/public/main/admin/user_edit.php b/public/main/admin/user_edit.php index 2f5f58cb6e..c107c88897 100644 --- a/public/main/admin/user_edit.php +++ b/public/main/admin/user_edit.php @@ -537,14 +537,8 @@ $content = Display::toolbarAction('toolbar-user-information', [implode(PHP_EOL, $bigImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL); $normalImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG); -$content .= '
'; -$content .= '
'; -// Display form + $content .= $form->returnForm(); -$content .= '
'; -$content .= '
'; -$content .= ''; -$content .= '
'; $tpl = new Template($tool_name); $tpl->assign('content', $content); diff --git a/public/main/inc/lib/display.lib.php b/public/main/inc/lib/display.lib.php index 273e5f83b9..569fc7fea1 100644 --- a/public/main/inc/lib/display.lib.php +++ b/public/main/inc/lib/display.lib.php @@ -2547,7 +2547,7 @@ class Display { $col = count($contentList); $html = '
'; - $html .= '
'; + $html .= '
'; foreach ($contentList as $item) { $html .= '
'.$item.'
'; } diff --git a/public/main/inc/lib/formvalidator/Element/DatePicker.php b/public/main/inc/lib/formvalidator/Element/DatePicker.php index 61cd0f9ac4..77b1188aba 100644 --- a/public/main/inc/lib/formvalidator/Element/DatePicker.php +++ b/public/main/inc/lib/formvalidator/Element/DatePicker.php @@ -72,58 +72,6 @@ class DatePicker extends HTML_QuickForm_text ); } - /** - * @param string $layout - * - * @return string - */ - public function getTemplate($layout) - { - $size = $this->calculateSize(); - - switch ($layout) { - case FormValidator::LAYOUT_INLINE: - return ' -
- - - {element} -
'; - break; - case FormValidator::LAYOUT_HORIZONTAL: - return ' -
- -
- {icon} - {element} - -

{label_2}

- - - - {error} - -
-
- - {label_3} - -
-
'; - break; - case FormValidator::LAYOUT_BOX_NO_LABEL: - return '{element}'; - break; - } - } - /** * Get the necessary javascript for this datepicker. * diff --git a/public/main/inc/lib/formvalidator/Element/DateTimePicker.php b/public/main/inc/lib/formvalidator/Element/DateTimePicker.php index 6e31e0a0c2..2d34c99d90 100644 --- a/public/main/inc/lib/formvalidator/Element/DateTimePicker.php +++ b/public/main/inc/lib/formvalidator/Element/DateTimePicker.php @@ -1,4 +1,5 @@ updateAttributes(['value' => $value]); } - /** - * @param string $layout - * - * @return string - */ - public function getTemplate($layout) - { - $size = $this->calculateSize(); - - switch ($layout) { - case FormValidator::LAYOUT_INLINE: - return ' -
- - - {element} -
'; - break; - case FormValidator::LAYOUT_HORIZONTAL: - return ' -
- -
- {icon} - {element} - -

{label_2}

- - - - {error} - -
-
- - {label_3} - -
-
'; - break; - case FormValidator::LAYOUT_BOX_NO_LABEL: - return '{element}'; - break; - } - } - /** * Get the necessary javascript for this datepicker. * diff --git a/public/main/inc/lib/formvalidator/FormValidator.class.php b/public/main/inc/lib/formvalidator/FormValidator.class.php index d37ca53723..92995aa76c 100644 --- a/public/main/inc/lib/formvalidator/FormValidator.class.php +++ b/public/main/inc/lib/formvalidator/FormValidator.class.php @@ -38,7 +38,7 @@ class FormValidator extends HTML_QuickForm ) { // Default form class. if (is_array($attributes) && !isset($attributes['class']) || empty($attributes)) { - $attributes['class'] = 'form-horizontal'; + $attributes['class'] = 'form-horizontal q-pt-md'; } if (isset($attributes['class']) && false !== strpos($attributes['class'], 'form-search')) { @@ -52,13 +52,18 @@ class FormValidator extends HTML_QuickForm switch ($layout) { case self::LAYOUT_HORIZONTAL: - $attributes['class'] = 'form-horizontal'; + $attributes['class'] = 'w-full '; + break; + case self::LAYOUT_BOX_SEARCH: + $attributes['class'] = 'w-full flex gap-2'; + $formTemplate = $this->getInLineTemplate(); break; case self::LAYOUT_INLINE: - $attributes['class'] = 'form-inline'; + $attributes['class'] = ' flex gap-1 '; + $formTemplate = $this->getInLineTemplate(); break; case self::LAYOUT_BOX: - $attributes['class'] = 'form-inline-box'; + $attributes['class'] = 'flex gap-1 '; break; case self::LAYOUT_GRID: $attributes['class'] = 'form-grid'; @@ -70,11 +75,12 @@ class FormValidator extends HTML_QuickForm // Modify the default templates $renderer = &$this->defaultRenderer(); - $renderer->setFormTemplate($formTemplate); // Element template - if (isset($attributes['class']) && 'form-inline' === $attributes['class']) { + if ((isset($attributes['class']) && 'form-inline' === $attributes['class']) || + (self::LAYOUT_INLINE === $layout || self::LAYOUT_BOX_SEARCH === $layout) + ) { $elementTemplate = ' {label} {element} '; $renderer->setElementTemplate($elementTemplate); } elseif (isset($attributes['class']) && 'form-search' === $attributes['class']) { @@ -97,12 +103,14 @@ class FormValidator extends HTML_QuickForm } //Set Header template - $renderer->setHeaderTemplate('{header}'); + $renderer->setHeaderTemplate('

{header}

'); - //Set required field template - $this->setRequiredNote( - '* '.get_lang('Required field').'' - ); + $required = '* '.get_lang('Required field').''; + if ((self::LAYOUT_INLINE === $layout || self::LAYOUT_BOX_SEARCH === $layout)) { + $required = ''; + } + // Set required field template + $this->setRequiredNote($required); $noteTemplate = << @@ -112,23 +120,29 @@ EOT; $renderer->setRequiredNoteTemplate($noteTemplate); } - /** - * @return string - */ - public function getFormTemplate() + public function getFormTemplate(): string + { + return ' +
+
+ + {content} + {hidden} + +
+
+ '; + } + + public function getInLineTemplate(): string { return ' -
{content} -
{hidden} '; } - /** - * @return string - */ - public function getGridFormTemplate() + public function getGridFormTemplate(): string { return '