Skip to content

Instantly share code, notes, and snippets.

View draven3166's full-sized avatar

Ronald Nina Calla draven3166

View GitHub Profile
@draven3166
draven3166 / gist_empty_field_drupal.md
Last active September 7, 2023 23:17
How do you check if a field is empty in drupal 8^9^10 ?

How do you check if a field is empty in drupal 8^9^10 on Twig ?

In community of developers you can read more than one question about this topic reading a common feed is.

I have a field added to the content type of basic page. It is a select box, which is either checked or unchecked depending on whether or not the page is of the 'getting started' kind. I want to add the class 'getting-started' to the body element in the html if the page is a getting started page, i.e. the box is checked. I want to do this in the .theme file. So essentially I want to check too see if the field is empty, and if it isn't add the class to the body element. Any help would be much appreciated. Original post here

In development you have more than one reason to use or verify this

Really goes without saying that to customize you must enter the templates of the specific place to be able to verify if a field is empty or not. But t