PHP Notice: 'Array to string conversion' while making symfony form template -


i'm following a symfony tutorial in official documentation. when field type options symfony throws error "an exception has been thrown during rendering of template ("notice: array string conversion") in form_div_layout.html.twig @ line 13."

i have checked on google , typos, offending line, documentation seems be:

->add('duedate', datetype::class, array('widget' => 'single_text')) 

which straight documentation. context rest of file looks this:

<?php  namespace appbundle\controller;  use appbundle\entity\task;  use symfony\component\form\extension\core\type\texttype; use symfony\component\form\extension\core\type\datetype; use symfony\component\form\extension\core\type\submittype;  use sensio\bundle\frameworkextrabundle\configuration\route; use symfony\bundle\frameworkbundle\controller\controller; use symfony\component\httpfoundation\request;  class defaultcontroller extends controller {     /**      * @route("/", name="homepage")      */     public function indexaction(request $request)     {         // replace example code whatever need         return $this->render('default/index.html.twig', [             'base_dir' => realpath($this->getparameter('kernel.root_dir').'/..'),         ]);     }      /**      * @route("/form", name="formmma")      */     public function newaction(request $request)     {         // create task , give dummy data example         $task = new task();         $task->settask('write blog post');          $task->setduedate(new \datetime('tomorrow'));          $form = $this->createformbuilder($task)             ->add('task', texttype::class)            // ->add('duedate', datetype::class)             ->add('duedate', datetype::class, array('widget' => 'single_text'))            // ->add('duedate', null, array(            //     'widget' => 'single_text',            //     'required' => false            // ))              ->add('save', submittype::class, array('label' => 'create task'))             ->getform();          $form->handlerequest($request);          if ($form->issubmitted() && $form->isvalid()) {              // ... perform action, such saving task database               return $this->redirecttoroute('task_success');         }          return $this->render('default/new.html.twig', array(             'form' => $form->createview(),         ));     } } 

in controller put

     if ($form->issubmitted()) {         $datefrom=$booking->dateofarrival;         $booking->dateofarrival= new \datetime();         $booking->dateofarrival->setdate($datefrom->format('y'),$datefrom->format('m'),$datefrom->format('d'));} 

ps: "booking" model used in form


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -