I have a problem with Form in Symfony2,
This is mi form Code:
$form = $this->createFormBuilder($pedido)
->setAction($this->generateUrl("ec_main_guardar_pedido"))
->add('cliente','entity',array('class' =>'ECMainBundle:Clientes','property'=>'cliente'))
->add('fecha', 'date', array('widget' => 'single_text',
'format' => 'd-M-y',
'required' => 'false',
'read_only' => 'false'))
->add('fentrega', 'date',array('format' => 'yyyy-MM-dd'))
->add('estado','hidden', array('data' => '3'))
->add('Guardar', 'submit')
->getForm();
The field 'fecha' don't work, i test with another formats, but i dont have solution, always say 'null', i try to generate the javascript to show one calendar, but the problem is the same, always null.
If in the Entity add this:
public function __construct()
{
$this->lineas = new ArrayCollection();
$this->fecha= new \DateTime();
$this->fentrega= new \DateTime();
}
the field 'fecha' always is today.
And the field 'fentrega' with the widget choise work perfect.
Anyone can helpme please?
Thanks in advance.