Answers for "get if drupal 8 field is empty"

0

get if drupal 8 field is empty

if (!$entity->get('category')->isEmpty()) {
  /** @var EntityInterface $category */
  $category = $entity->get('category')->entity;
  $row['category']['data'] = [
    '#type' => 'link',
    '#title' => $category->get('name')->value,
    '#url' => $category->toUrl(),
  ];
}
else {
  $row['category'] = NULL;
}
Posted by: Guest on June-23-2020

Browse Popular Code Answers by Language