Created
December 18, 2014 11:35
-
-
Save deepakaryan1988/49ac39842e30ad350713 to your computer and use it in GitHub Desktop.
update field collection without saving entity
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
| http://alexrayu.com/blog/saveupdate-field-collection-without-nodesave | |
| // Get field collection (supposedly containing one image with meta data) | |
| $fc = entity_load('field_collection_item', array($fcid)); | |
| // If we were to have multi-value fc's, we weould have a cycle here in place of current() | |
| $fc = current($fc); | |
| // Get meta data. A custom function. | |
| $meta = custom_get_meta_data($fc); | |
| // Assign meta data | |
| $fc->field_title[LANGUAGE_NONE][0]['value'] = $meta->title; | |
| $fc->field_author_name[LANGUAGE_NONE][0]['value'] = $meta->author; | |
| $fc->field_caption[LANGUAGE_NONE][0]['value'] = $meta->caption; | |
| $fc->field_alt_text[LANGUAGE_NONE][0]['value'] = $meta->alt_text; | |
| $fc->field_short_caption[LANGUAGE_NONE][0]['value'] = $meta->short_caption; | |
| entity_save('field_collection_item', $fc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment