diff --git a/assets/styles/app.scss b/assets/styles/app.scss index 764d94d9a4e76b0fc06b03a39b21b2c672dc5c43..88a51f65d25fe1289ee46960449467a87a5f750a 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 1d931069dfae76b55a6a2db199e2b6e29f05f05d..b3db86defc1beac44d14e8bdc93ca68194acae44 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 2cd948f8ad634cd142ea68c0189b7587fbc56b26..655237b63084081fa63c446b6d94510098117ebd 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 7188f1ee43d0f1f34dafb2ad8114f01f54abd421..138137ce56fa5dd672d50308844ae4dea369f0cf 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) }}