Created
August 27, 2020 09:51
-
-
Save skounis/d23a76a5225ce0795bdb9f20525a8973 to your computer and use it in GitHub Desktop.
To extract the field value in Drupal 8
This file contains 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
// We can go the long way | |
$field = $group->some_field->first(); | |
// then | |
$reference_entity_id = $field->getValue()['target_id']; | |
// But there is a better way to do it | |
$reference_entity_id = $group->some_field->target_id; | |
// The same way we can extract simple types, like string and integer | |
$field_value = $group->some_field->value; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment