In entity node, I want to check if 'abc' field exists or not. If exists, I will get its value by $value->get('abc').

But the content type where this field doesn't exists, gives error:

The website encountered an unexpected error. Please try again later.

How to check if field exists in an entity?


1 Answer 1


Since Drupal 8, you can use FieldableEntityInterface::hasField().


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.