Ana içeriğe atla

Check if Entity has a field programmatically

Taskin
Taskin
5 dakika okuma süresi
<?php

// Get entity storage.
$entityName = 'node';
$entityStorage = \Drupal::service('entity.manager')->getStorage($entityName);
// Load the entity by $eid - entity id.
$eid = 1;
$entity = $entityStorage->load($eid);
// Load field type by field name.
$fieldName = 'field_custom';
// Check if the entity has this $fieldName.
if ($entity->hasField($fieldName)) {
    // Do something...
}

Ofislerimiz

Drupart Locations

Ofislerimiz

Drupart AR-GE

GOSB Teknopark Hi-Tech Bina 3.Kat B3 Gebze - KOCAELİ

+90 262 678 8872

+90 216 706 12 58 

[email protected]

Londra

151 West Green Road, London, England

+44 203 815 6478

[email protected]

Newark

112 Capitol Trail Suite, A437 Newark DE, 19711

+1 (740) 666 6255

[email protected]

Wiesbaden

Hinterbergstraße 27
65207 Wiesbaden
Deutschland

+49 (0) 6151 – 492 70 23

[email protected]