I have a file entity
with some custom fields, for example a date field.
How can I programmatically set the field values?
If I, for example, set date-field value with a DrupalDateTime
object, I get an error on saving the entity.
$entity->set('field_myname', $drupalDateTimeObject);
$entity->save();
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_myname_value'
So I assume there needs to be a transition between the DateTime object and the actual field value. How can this transition be done dynamic, if the field types are dynamic?