I would like to create a html choice field with datetime entries of the last edits made. When taking any other fields in the database this works, with datetime it doesn't.
In the formtype I have
class MemberlistType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('CreatedAt', 'entity', array(
'mapped' => false,
'class' => 'TestProject\TestBundle\Entity\Memberlist',
'property' => 'created_at'
))
`
In the view I have
{{form_label(form.children.memberlists[0].children.CreatedAt}}
{{form_widget(form.children.memberlists[0].children.CreatedAt}}
{{form_errors(form.children.memberlists[0].children.CreatedAt)}}
And I get:
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 /var/www/symfony/vendor/symfony/symfony
/src/Symfony/Component/Translation/Translator.php line 188") in
TestprojectTestBundle:Default:updateData.html.twig at line 77
How can I convert this datetime to string in an easy way?