At the moment there is no way to get widget settings inside hook_field_is_empty(). This would be handy for making custom fields and widgets.

Comments

fago’s picture

Yep, having $instance there would help a lot for doing a proper multiple-value handling for complex field types like addressfield or fieldcollection. That way you could say that form widgets having default values have to be considered empty.

(the default value is part of $instance).

See issues
#1239946: Embedded field collection items with a default value result in new items on save
#1263316: Configurable non-empty value conditions

However, I fear backporting this qualifies as API change as it would change the necessary hook arguments.

johnv’s picture

Ja, that is a pity. For now, using hook_field_presave() is the next best thing.

johnv’s picture

You can find my D7 work-around implementation here. IMO it is pretty generic.