Skip to content
Snippets Groups Projects
Commit 7cd59c6b authored by Angie Byron's avatar Angie Byron
Browse files

#548630 by bjaspan: Document hook_field_is_empty().

parent 1724844d
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -125,6 +125,7 @@ function hook_fieldable_info_alter(&$info) { ...@@ -125,6 +125,7 @@ function hook_fieldable_info_alter(&$info) {
* @see hook_field_delete(). * @see hook_field_delete().
* @see hook_field_delete_revision(). * @see hook_field_delete_revision().
* @see hook_field_sanitize(). * @see hook_field_sanitize().
* @see hook_field_is_empty().
* *
* The Field Types API also defines two kinds of pluggable handlers: widgets * 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 * 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 ...@@ -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) { 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. * Expose Field API widget types.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment