Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.45 KB | None | 0 0
  1. /**
  2.      * @Route("/profile/posts", name="admin_posts")
  3.      */
  4.     public function postsAction()
  5.     {
  6.         $postRepo   = $this->getDoctrine()->getRepository(Posts::class);
  7.  
  8.         $posts      = $postRepo->findAll([],['limit' => 10]);
  9.  
  10.         $form       = $this->createFormBuilder((new Posts),['method' => 'post','action' => '/profile/posts/save'])
  11.                         ->add('title',TextType::class,
  12.                             ['attr' => [
  13.                                 'class' => 'form-control'
  14.                             ]]
  15.                         )
  16.                         ->add('text',TextareaType::class,
  17.                             ['attr' => [
  18.                                 'class' => 'form-control'
  19.                             ]]
  20.                         )
  21.                         ->add('attach',FileType::class,
  22.                             ['attr' => [
  23.                                 'class' => 'form-control'
  24.                             ]]
  25.                         )
  26.                         ->add('save',SubmitType::class,
  27.                             ['attr' => [
  28.                                 'class' => 'btn btn-xs btn-success'
  29.                             ]]
  30.                         )
  31.                         ->getForm();
  32.  
  33.         return $this->render('AppBundle:Profile:posts.html.twig',
  34.             [
  35.                 'form'  => $form->createView(),
  36.                 'posts' => $posts
  37.             ]
  38.         );
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement