PHP Classes

File: vendor/sensio/generator-bundle/Resources/skeleton/crud/actions/new.php.twig

Recommend this page to a friend!
  Classes of Murat Cileli   Papernic   vendor/sensio/generator-bundle/Resources/skeleton/crud/actions/new.php.twig   Download  
File: vendor/sensio/generator-bundle/Resources/skeleton/crud/actions/new.php.twig
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Papernic
Manage documents colaboratively
Author: By
Last change:
Date: 7 years ago
Size: 1,514 bytes
 

Contents

Class file image Download
/** {% block phpdoc_method_header %} * Creates a new {{ entity }} entity. {% endblock phpdoc_method_header %} * {% block phpdoc_method_annotations %} {% if 'annotation' == format %} * @Route("/new", name="{{ route_name_prefix }}_new") * @Method({"GET", "POST"}) {% endif %} {% endblock phpdoc_method_annotations %} */ {% block method_definition %} public function newAction(Request $request) {% endblock method_definition %} { {% block method_body %} ${{ entity_singularized }} = new {{ entity_class }}(); $form = $this->createForm('{{ namespace }}\Form\{{ entity_class }}Type', ${{ entity_singularized }}); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist(${{ entity_singularized }}); $em->flush(); {% if 'show' in actions -%} return $this->redirectToRoute('{{ route_name_prefix }}_show', array('id' => ${{ entity_class|lower }}->getId())); {%- else -%} return $this->redirectToRoute('{{ route_name_prefix }}_index')); {%- endif %} } {% endblock method_body %} {% block method_return %} return $this->render('{{ entity|lower|replace({'\\': '/'}) }}/new.html.twig', array( '{{ entity_singularized }}' => ${{ entity_singularized }}, 'form' => $form->createView(), )); {% endblock method_return %} }