mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 17:39:06 +02:00
Show infos about filename and filesize on attachment edit tab.
This commit is contained in:
parent
3a11933a89
commit
09a5948149
3 changed files with 45 additions and 2 deletions
|
@ -102,6 +102,7 @@ class PartController extends AbstractController
|
|||
[
|
||||
'part' => $part,
|
||||
'form' => $form->createView(),
|
||||
'attachment_helper' => $attachmentHelper
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -113,7 +114,8 @@ class PartController extends AbstractController
|
|||
* @param TranslatorInterface $translator
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator)
|
||||
public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator,
|
||||
AttachmentHelper $attachmentHelper)
|
||||
{
|
||||
$new_part = new Part();
|
||||
|
||||
|
@ -129,6 +131,13 @@ class PartController extends AbstractController
|
|||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
//Upload passed files
|
||||
$attachments = $form['attachments'];
|
||||
foreach ($attachments as $attachment) {
|
||||
/** @var $attachment FormInterface */
|
||||
$attachmentHelper->upload( $attachment->getData(), $attachment['file']->getData());
|
||||
}
|
||||
|
||||
$em->persist($new_part);
|
||||
$em->flush();
|
||||
$this->addFlash('success', $translator->trans('part.created_flash'));
|
||||
|
@ -142,6 +151,7 @@ class PartController extends AbstractController
|
|||
[
|
||||
'part' => $new_part,
|
||||
'form' => $form->createView(),
|
||||
'attachment_helper' => $attachmentHelper
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue