geoB
geoB

Reputation: 4704

Array to string conversion error rendering a fixed date

An entity's add date is assigned when it is created and therefore cannot be edited. If the add date is rendered on the entity's edit form with {{ form.addDate.vars.value|date('m/d/Y') }} the error

An exception has been thrown during the rendering of a template ("Notice: Array to string conversion")...

is thrown.

It is possible to work around this with

{% set added = form.addDate.vars.value %}
Added {{ added.month~'/'~added.day~'/'~added.year }}

But I wonder if I missed something. Does the documentation somewhere address this?

Upvotes: 1

Views: 579

Answers (1)

Matteo
Matteo

Reputation: 39380

Try access directly from the main form instead access from the subform field as follow:

{{ form.vars.value.addDate|date('m/d/Y') }}

Hope this help

Upvotes: 1

Related Questions