From 41fa04dfa93619d943d4f51290321da901e461d4 Mon Sep 17 00:00:00 2001 From: Camille Simiand <camille.simiand@tetras-libre.fr> Date: Thu, 24 Feb 2022 09:39:06 +0100 Subject: [PATCH] Add previous video url as placeholder --- assets/styles/app.scss | 4 ++++ src/Controller/ProjectController.php | 6 +++++- src/Form/EditVideoUrlFormType.php | 4 +++- templates/project/edit_video_url.html.twig | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/assets/styles/app.scss b/assets/styles/app.scss index 764d94d..88a51f6 100644 --- a/assets/styles/app.scss +++ b/assets/styles/app.scss @@ -160,4 +160,8 @@ button[type=submit]{ .remove-link { font-size: 0.9rem; +} + +.video-url { + max-width: 900px; } \ No newline at end of file diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php index 1d93106..b3db86d 100755 --- a/src/Controller/ProjectController.php +++ b/src/Controller/ProjectController.php @@ -6,6 +6,7 @@ use App\Entity\Capsule; use App\Exception\ZipArchiveNotOpeningException; use App\Form\EditVideoUrlFormType; use App\Repository\CapsuleRepository; +use App\Retriever\ProjectRetriever; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Config\Util\Exception\XmlParsingException; use Symfony\Component\Filesystem\Exception\FileNotFoundException; @@ -199,7 +200,10 @@ class ProjectController extends AbstractController return $this->redirectToRoute('capsule_list'); } - $form = $this->createForm(EditVideoUrlFormType::class); + $project_retriever = new ProjectRetriever($capsule); + $current_video_url = $project_retriever->getVideoUrl(); + + $form = $this->createForm(EditVideoUrlFormType::class, ['current_video_url' => $current_video_url]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { diff --git a/src/Form/EditVideoUrlFormType.php b/src/Form/EditVideoUrlFormType.php index 2cd948f..655237b 100755 --- a/src/Form/EditVideoUrlFormType.php +++ b/src/Form/EditVideoUrlFormType.php @@ -14,6 +14,8 @@ class EditVideoUrlFormType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { + $current_video_url = $options['data']['current_video_url']; + $builder ->add( 'new_video_url', @@ -21,7 +23,7 @@ class EditVideoUrlFormType extends AbstractType [ 'constraints' => [new NotBlank(['message' => 'capsule.video_url.not_blank'])], 'label' => 'capsule.edit.video_url.text', - 'empty_data' => '' + 'data' => $current_video_url ] ) ->add( diff --git a/templates/project/edit_video_url.html.twig b/templates/project/edit_video_url.html.twig index 7188f1e..138137c 100644 --- a/templates/project/edit_video_url.html.twig +++ b/templates/project/edit_video_url.html.twig @@ -16,7 +16,7 @@ </div> {{ form_start(editVideoUrlForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-column justify-content-center'}}) }} - {{ form_row(editVideoUrlForm.new_video_url, {'row_attr': {'class' : 'm-auto mb-4 col-6'}}) }} + {{ form_row(editVideoUrlForm.new_video_url, {'row_attr': {'class' : 'video_url m-auto mb-4 col-11 col-sm-10 col-md-9 col-xl-8'}}) }} {{ form_row(editVideoUrlForm.save, {'row_attr': {'class' : 'm-auto mb-5 col-2'}}) }} {{ form_end(editVideoUrlForm) }} -- GitLab