edit_category.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. $form = new FormValidator('edit_category', 'post', $baseUrl."action=edit_category&id={$category->getId()}");
  4. if (api_get_configuration_value('save_titles_as_html')) {
  5. $form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'TitleAsHtml']);
  6. } else {
  7. $form->addText('title', get_lang('Title'));
  8. $form->applyFilter('title', 'trim');
  9. }
  10. $form->addHtmlEditor('description', get_lang('Description'), false, false, ['ToolbarSet' => 'Minimal']);
  11. $form->addButtonUpdate(get_lang('Update'));
  12. $form->setDefaults([
  13. 'title' => $category->getTitle(),
  14. 'description' => $category->getDescription(),
  15. ]);
  16. if ($form->validate()) {
  17. $values = $form->exportValues();
  18. $category
  19. ->setTitle($values['title'])
  20. ->setDescription($values['description']);
  21. $em->persist($category);
  22. $em->flush();
  23. Display::addFlash(
  24. Display::return_message(get_lang('Updated'), 'success')
  25. );
  26. header("Location: $baseUrl");
  27. exit;
  28. }
  29. $toolName = get_lang('EditCategory');
  30. $interbreadcrumb[] = [
  31. 'name' => get_lang('Portfolio'),
  32. 'url' => $baseUrl,
  33. ];
  34. $actions[] = Display::url(
  35. Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM),
  36. $baseUrl
  37. );
  38. $content = $form->returnForm();