Is there a way to check, in a preprocess function, if the value of a field within the preprocess is empty?
I'm getting an Error: Call to a member function isEmpty()
error during the processfollowing error.
Call to a member function isEmpty()
function iom_preprocess_block__twitterfeed(&$variables) {
// Get the twitter_username field from node.
$twitterUsername = \Drupal::routeMatch()
->getParameter('node')
->get('field_twitter_username')
->value;
if ($twitterUsername->isEmpty()) {
dump("Empty");
}
else {
dump("Not Empty");
}
}