Last active
October 19, 2018 12:04
-
-
Save DanLaufer/1674309c5914f771844d7f0e5854f80a to your computer and use it in GitHub Desktop.
Drupal 8 - Check Nodes for a Specific Form Reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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