Guest User

Untitled

a guest
Dec 5th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppBundle\Controller;
  4.  
  5.  
  6. use AppBundle\Entity\Oferty;
  7. use AppBundle\Entity\Preferencje_Oferty;
  8. use AppBundle\Entity\Preferencje;
  9. use AppBundle\Entity\Wyposazenie_Oferty;
  10. use AppBundle\Entity\Wyposazenie_Oferty_Oferty;
  11. use AppBundle\Entity\Wyposazenie;
  12. use AppBundle\Form\NoweOgloszenie;
  13. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  14. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\Validator\Tests\Fixtures\Entity;
  17. use Symfony\Component\HttpFoundation\Response;
  18. use Symfony\Component\Validator\Mapping\ClassMetadata;
  19. use Symfony\Component\Validator\Constraints;
  20. use Symfony\Component\Validator\Constraints\NotBlank;
  21. use Symfony\Component\Validator\Constraints\Email;
  22. use Symfony\Component\Validator\Constraints\MinLength;
  23. use Symfony\Component\Validator\Constraints\MaxLength;
  24.  
  25.  
  26. class NoweOgloszenieController extends Controller
  27. {
  28. /**
  29. * @Route("/NoweOgloszenie", name="NoweOgloszenie")
  30. */
  31.  
  32. public function newAction(Request $request)
  33. {
  34. $task = new Oferty();
  35.  
  36. $form = $this->createForm(new NoweOgloszenie());
  37. $form->handleRequest($request);
  38. if ($form->isValid()) {
  39.  
  40. $validator = $this->get('validator');
  41. $errors = $validator->validate($Oferta);
  42.  
  43. if (count($errors) > 0) {
  44. return new Response(print_r($errors, true));
  45. } else {
  46. return $this->redirectToRoute('_oferta',array('idOferty' => $Oferta->getIdOferty()));
  47. }
  48. }
  49.  
  50. return $this->render(':Szablony:noweogloszenie.html.twig', array(
  51. 'form' => $form->createView(),
  52. ));
  53. }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment