public function myAction(Request $request) { // create a task and give it some dummy data for this example $task = new Student(); $task->setTask('Write a blog post'); $task->setDueDate(new \DateTime('tomorrow')); $form = $this->createFormBuilder($task)->add('task', TextType::class)->add('dueDate', DateType::class)->add('save', SubmitType::class, array('label' => 'Create Task'))->getForm(); return $this->render('default/new.html.twig', array('form' => $form->createView())); }