function hook_field_collection_is_empty_alter in Field collection 8.3
Same name and namespace in other branches
- 8 field_collection.api.php \hook_field_collection_is_empty_alter()
- 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
bool $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.
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;
}
}