1 | initial version |
In Drupal 8, you can use the function empty()
to check if a field is vacant or not.
Here's an example code snippet:
if (empty($node->field_name->value)) {
// The field is vacant
} else {
// The field has content
}
In the above example, replace field_name
with the machine name of the field you want to check.
Note: If the field uses a different type of data structure (e.g. for multi-value fields), you may need to adjust the syntax accordingly.