From 7cd59c6bc49b9a8608eb07304b265a59fe51e63f Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Fri, 14 Aug 2009 05:16:26 +0000 Subject: #548630 by bjaspan: Document hook_field_is_empty(). --- modules/field/field.api.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'modules/field/field.api.php') diff --git a/modules/field/field.api.php b/modules/field/field.api.php index 6f40c2009..39618ea08 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -125,6 +125,7 @@ function hook_fieldable_info_alter(&$info) { * @see hook_field_delete(). * @see hook_field_delete_revision(). * @see hook_field_sanitize(). + * @see hook_field_is_empty(). * * The Field Types API also defines two kinds of pluggable handlers: widgets * and formatters, which specify how the field appears in edit forms and in @@ -518,6 +519,24 @@ function hook_field_delete_revision($obj_type, $object, $field, $instance, $item function hook_field_prepare_translation($obj_type, $object, $field, $instance, $items) { } +/** + * Define what constitutes an empty item for a field type. + * + * @param $item + * An item that may or may not be empty. + * @param $field + * The field to which $item belongs. + * @return + * TRUE if $field's type considers $item not to contain any data; + * FALSE otherwise. + */ +function hook_field_is_empty($item, $field) { + if (empty($item['value']) && (string)$item['value'] !== '0') { + return TRUE; + } + return FALSE; +} + /** * Expose Field API widget types. * -- cgit v1.2.3