Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DanLaufer/1674309c5914f771844d7f0e5854f80a to your computer and use it in GitHub Desktop.
Save DanLaufer/1674309c5914f771844d7f0e5854f80a to your computer and use it in GitHub Desktop.
Drupal 8 - Check Nodes for a Specific Form Reference
$query = \Drupal::entityQuery('node');
$node_ids = $query
->condition('status', 1)
->exists('field_form_reference')
->execute();
foreach($node_ids as $node_id) {
$node = \Drupal\node\Entity\Node::load($node_id);
$referenced_form = $node->get('field_form_reference')->referencedEntities();
foreach($referenced_form as $da_form) {
print_r('nid '.$node_id.': ');
print_r($da_form->id()); echo '<br />';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment