Spin-off from #501428-143: Date and time field type in core. If a module implements hook_field_load() to add something that later functions (e.g., formatters) expect to be there (for example, in the case of datetime.module, it adds a $item['date'] object derived from the $item['value'] string), then EntityFormController::submit() overrides the field items with their new values, and destroys the stuff added by hook_field_load(), breaking those other functions unless the entity is saved and reloaded.

Not sure how to solve this yet. EntityNG supports a better way of implementing calculated fields, and that could be part of the answer.


yched’s picture

I suspect that's already the case in D7 with e.g. the elements added to file field values by file_field_load().

On form submission, $entity->$field_name[$language] gets overwritten with the values taken out of the form submit data.
So after that, $entity->$field_name[$language] contains something that was not loaded and has not gone through hook_field_load().
Likewise if you programmatically change a field value before saving it.

Berdir’s picture

Issue summary:View changes
Status:Active» Closed (duplicate)

I think this is solved. load is now getCachedData() and designed to only operate when caching field values, field item classes must be implemented to always work and compute what they need. DateItem has been updated to do that.