Skip to content

Commit

Permalink
Course: Fix undefined 'name' key error in course category edit - refs…
Browse files Browse the repository at this point in the history
… BT#22252
  • Loading branch information
christianbeeznest committed Dec 16, 2024
1 parent d9821d2 commit c25207d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions public/main/admin/course_category.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
if (isset($_POST['formSent']) && $_POST['formSent']) {
$categoryEntity = CourseCategory::add(
$_POST['code'],
$_POST['name'],
$_POST['title'],
$_POST['auth_course_child'],
$_POST['description'],
$parentId,
Expand All @@ -92,7 +92,7 @@
if (isset($_POST['formSent']) && $_POST['formSent']) {
$categoryEntity = CourseCategory::edit(
$categoryId,
$_REQUEST['name'],
$_REQUEST['title'],
$_REQUEST['auth_course_child'],
$_REQUEST['code'],
$_REQUEST['description']
Expand Down Expand Up @@ -144,15 +144,15 @@

if ('true' === api_get_setting('editor.save_titles_as_html')) {
$form->addHtmlEditor(
'name',
'title',
get_lang('Category name'),
true,
false,
['ToolbarSet' => 'TitleAsHtml']
);
} else {
$form->addElement('text', 'name', get_lang('Category name'));
$form->addRule('name', get_lang('Please enter a code and a name for the category'), 'required');
$form->addElement('text', 'title', get_lang('Category name'));
$form->addRule('title', get_lang('Please enter a code and a name for the category'), 'required');
}

$form->addRule('code', get_lang('Please enter a code and a name for the category'), 'required');
Expand Down Expand Up @@ -191,8 +191,9 @@

$asset = $assetRepo->find($categoryInfo['asset_id']);
$image = $assetRepo->getAssetUrl($asset);
$escapedImageUrl = htmlspecialchars($image, ENT_QUOTES, 'UTF-8');

$form->addLabel(get_lang('Image'), "<img src=$image />");
$form->addLabel(get_lang('Image'), "<img src='$escapedImageUrl' alt='Image' />");
}

if ('edit' === $action && !empty($categoryInfo)) {
Expand Down

0 comments on commit c25207d

Please sign in to comment.