Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @Route("/agency/post", name="agency_post")
- */
- public function agencyNewAd(Request $request)
- {
- // $agency = $this->get('security.token_storage')->getToken()->getUser(); ( this didn't worked .. )
- $form = $this->createForm(AgencyNewAdType::class, array(
- 'postedBy' => $this->getUser(),
- ));
- $form->handleRequest($request);
- if ($form->isSubmitted() && $form->isValid()) {
- $ad = $form->getData();
- // save the task to the database
- $em = $this->getDoctrine()->getManager();
- $em->persist($ad);
- $em->flush();
- // return new Response('Saved new Post with id ' . $ad->getId());
- return $this->redirectToRoute('agency_admin');
- }
- return $this->render('agency/new_ad.html.twig', [
- 'adForm' => $form->createView()
- ]);
- }
Add Comment
Please, Sign In to add comment