I am learning symfony2 and I created one form in the controller, which is below. controller file as DefaultController.php
namespace Banner\TestBundle\Controller; use Banner\TestBundle\Entity\Contact; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Banner\TestBundle\Entity\Task; use Symfony\Components\HttpFoundation\Request; class DefaultController extends Controller { public function newAction(Request $request) { echo "The controller is called "; $task = new Task(); $task->setTask("Write a blog Post "); $task->setDueDate(new DateTime('tomorrow')); $form = $this->createFormBuilder($task) ->add('task','text ') ->add('duedate','date') ->getForm(); return $this->render('BannerTestBundle:default:zoo.html.twig',array('form'=>$form->createView())); } }
my routing file is below. routing.yml
task_new: pattern: /task/{request} defaults: { _controller: BannerTestBundle:Default:new}
and the zoo.html.twig file is below.
{% extends '::page.html.twig' %} {% block title %}The Zoo{% endblock %} {% block content %} <form action="{{ path('task_new') }}" method="post" {{ form_enctype(form) }}> {{ form_widget(form) }} <input type="submit"> </form> {% endblock %}
when I pass "task / GET" in my url, it will show that "Request does not exist." error 500 '.
what I basically want to do is when I pass the url zoo.html.twig. I want to show the form in zoo.html.twig.
source share