diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index fac385b..d7c0f74 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -2,6 +2,8 @@ namespace App\Controller; +use App\Entity\Offering; +use App\Form\OfferingFormType; use App\Repository\OfferingRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -26,4 +28,17 @@ class AppController extends AbstractController 'user' => $this->getUser(), ]); } + + #[Route('/new', name: 'new_listing')] + public function new_listing(): Response + { + $offering = new Offering(); + $form = $this->createForm(OfferingFormType::class, $offering); + + + return $this->render('app/new_listing.html.twig', [ + 'user' => $this->getUser(), + 'offering_form' => $form->createView(), + ]); + } } diff --git a/src/Form/OfferingFormType.php b/src/Form/OfferingFormType.php new file mode 100644 index 0000000..41fa2b4 --- /dev/null +++ b/src/Form/OfferingFormType.php @@ -0,0 +1,30 @@ +add('createdAt') + ->add('title') + ->add('photoFilename') + ->add('zipCode') + ->add('description') + ->add('byUser') + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Offering::class, + ]); + } +} diff --git a/templates/app/new_listing.html.twig b/templates/app/new_listing.html.twig new file mode 100644 index 0000000..6878753 --- /dev/null +++ b/templates/app/new_listing.html.twig @@ -0,0 +1,5 @@ +{% extends 'base.html.twig' %} + +{% block body %} + {{ form(offering_form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/base.html.twig b/templates/base.html.twig index 6207407..9fa757b 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -31,6 +31,9 @@