I'm currently trying to add a form field with datetimepicker, as i'm submiting im getting the following error
This value is not valid. pesagem1
Symfony\Component\Validator\ConstraintViolation
Object(Symfony\Component\Form\Form).children[pesagem1] = 27/04/2016 23:59
Caused by:
Symfony\Component\Form\Exception\TransformationFailedException
Unable to reverse value for property path "pesagem1": DateTime::__construct(): Failed to parse time string (27/04/2016 23:59) at position 0 (2): Unexpected character
Caused by:
Symfony\Component\Form\Exception\TransformationFailedException
DateTime::__construct(): Failed to parse time string (27/04/2016 23:59) at position 0 (2): Unexpected character
Caused by:
Exception
DateTime::__construct(): Failed to parse time string (27/04/2016 23:59) at position 0 (2): Unexpected character
this is my entity + form
//entity
/** @ORM\Column(type="datetime") */
private $pesagem1;
//FORM
->add('pesagem1','datetime', array(
'widget' => "single_text",
'html5' => false,
'date_format'=>"dd/MM/yyyy hh:mm",
'attr'=>array(
'class'=>'datetimepickz form-control',
'style' => 'width: 70%',
'data-format'=>"dd/MM/yyyy hh:mm"
)
)
)
js + twig
$('.datetimepickz').datetimepicker({
locale: moment.locale('pt')
});
<div class="form-group">
<label>Primeira Pesagem</label>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envira"></i></span>
{{ form_widget(form.pesagem1) }}
</div>
<div>
{{ form_errors(form.pesagem1) }}
</div>
</div>
Seams like the string is "correct" according to symfony2 profiler, already tried with date format dd/mm/yyy hh:mm , d/m/Y hh:mm. and all returns the same problem.
Any help or hints would be much appreciated. ty