Date adds default values to new nodes. Those default values must only be applied to new nodes or you would end up possibly wiping out a user-supplied value later. So we have to find the entity a field is attached to and see if it has an id yet.

There is an api that will tell us the id field for the entity type but there is no consistent way to find the entity object in a field form so we can see if the id is empty. We have a method that works for users and nodes, but there is absolutely no consistency in the way that other entities provide the original entity to the field module when attaching the field to the entity.

http://drupalcode.org/project/date.git/commit/a581d17 is the current attempt to fix this that gets it working for nodes and users and field collections. More work is needed to try to find a reliable way to identify this information across other (or all) entity types.

Comments

KarenS’s picture

Status: Active » Fixed

After going down lots of rat holes, I finally figured out a way to reliably tell if the fields are being attached to a new entity so we know when they need default values.

There is NO good way to tell that from hook_widget, but we have the entity available during hook_field_widget_properties_alter(), so I can set a flag at that point and then check it later in hook_widget().

http://drupalcode.org/project/date.git/commit/6d544a9

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.