PMoubed PMoubed - 4 months ago 45
PHP Question

Symfony2, How to add a hidden date type field to a form ?

I am trying the scenario below :

// IN myclassType

public function buildForm(FormBuilder $builder, array $options)
->add('date', 'hidden' )

// in myclass
class myclass
//.. Other stuff

* @ORM\Column(type="date")
* @var date $date
protected $date;


while rendering I get this error :

An exception has been thrown during the rendering of a template ("Catchable Fatal Error:
Object of class DateTime could not be converted to string in
C:\wamp\www\PMI_sf2\app\cache\dev\twig\fb\40\8957f80f2358a6f4112c3427b387.php line 684") in
form_div_layout.html.twig at line 171.

Any idea how I can make a Date type field hidden !??



    ->add('date',null,array( 'attr'=>array('style'=>'display:none;')) )