You are here

function hook_field_collection_is_empty_alter in Field collection 8

Same name and namespace in other branches
  1. 8.3 field_collection.api.php \hook_field_collection_is_empty_alter()
  2. 7 field_collection.api.php \hook_field_collection_is_empty_alter()

Alter whether a field collection item is considered empty.

This hook allows modules to determine whether a field collection is empty before it is saved.

Parameters

boolean $is_empty: Whether or not the field should be considered empty.

\Drupal\field_collection\Entity\FieldCollectionItem $item: The field collection we are currently operating on.

File

./field_collection.api.php, line 24
Contains API documentation and examples for the Field collection module.

Code

function hook_field_collection_is_empty_alter(&$is_empty, \Drupal\field_collection\Entity\FieldCollectionItem $item) {
  if (isset($item->my_field) && empty($item->my_field)) {
    $is_empty = TRUE;
  }
}