I have date field in symfony2 which is rendered by two inputs:
$builder
->add('timeStart','datetime',array(
'date_widget' => 'single_text',
'time_widget' => 'single_text',
'date_format' => 'yyyy-MM-dd',
'data' => new \DateTime('now')
))
how to set attributes for each input? When I add attr=>array('some_attr'=>'some_value')
it is added to the div in which those inputs are, not to each input.
You need to set each's input attribute when rendering inside the twig template. Something like this would do:
{{ form_widget(form.timeStart, { attributes1 } ) }}
And
{{ form_widget(form.timeStart, { attributes2 } ) }}
Take a look at the docs.