PMoubed PMoubed - 1 year ago 160
PHP Question

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

I am trying the scenario below :



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


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 !??

Answer Source


    ->add('date',null,array( 'attr'=>array('style'=>'display:none;')) )
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download