Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/main/portfolio/edit_item.php

53 lines
1.6 KiB

<?php
/* For licensing terms, see /license.txt */
$categories = $em
->getRepository('ChamiloCoreBundle:PortfolioCategory')
->findBy([
'user' => $user,
]);
$form = new FormValidator('edit_portfolio', 'post', $baseUrl."action=edit_item&id={$item->getId()}");
$form->addText('title', get_lang('Title'));
$form->addHtmlEditor('content', get_lang('Content'), true, false, ['ToolbarSet' => 'NotebookStudent']);
$form->addSelectFromCollection('category', get_lang('Category'), $categories, [], true, '__toString');
$form->addButtonUpdate(get_lang('Update'));
$form->setDefaults([
'title' => $item->getTitle(),
'content' => $item->getContent(),
'category' => $item->getCategory() ? $item->getCategory()->getId() : '',
]);
if ($form->validate()) {
$values = $form->exportValues();
$currentTime = new DateTime(api_get_utc_datetime(), new DateTimeZone('UTC'));
$item
->setTitle($values['title'])
->setContent($values['content'])
->setUpdateDate($currentTime)
->setCategory(
$em->find('ChamiloCoreBundle:PortfolioCategory', $values['category'])
);
$em->persist($item);
$em->flush();
Display::addFlash(
Display::return_message(get_lang('Updated'), 'success')
);
header("Location: $baseUrl");
exit;
}
$toolName = get_lang('EditPortfolioItem');
$interbreadcrumb[] = [
'name' => get_lang('Portfolio'),
'url' => $baseUrl,
];
$actions[] = Display::url(
Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM),
$baseUrl
);
$content = $form->returnForm();