Created
October 1, 2013 16:48
-
-
Save grzegorznowak/6781538 to your computer and use it in GitHub Desktop.
How to manipulate Drupal 7's fields, based on entity reference example.
Minus validation, duplicates check, etc. Only the core logic.
Please comment if you think it's substantially wrong.
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
$node = node_load($nid); | |
$node_wrapped = entity_metadata_wrapper('node', $node); | |
$references = $collection_node->[name_of_reference_field]->value(); | |
// append new reference (note no sanity checks are included with this Gist) | |
$references[] = node_load($referenced_nid); | |
$collection_node->field_cards_reference->set($references); | |
$collection_node->save(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment