Created
March 10, 2015 14:43
-
-
Save kristianb21/e7006da999cb0bf2ef86 to your computer and use it in GitHub Desktop.
PHP-D7-Create Entity
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
$entity_type = 'entity_type'; | |
$entity = entity_create($entity_type, array( | |
'title' => 'Lorem Ipsum', | |
'type'=>'bunble_type', | |
// 'field_custom_field' => array( | |
// 'und' => array('value') | |
// ), | |
) | |
); | |
$wrapper = entity_metadata_wrapper($entity_type, $entity); | |
$wrapper->uid = $user->uid; | |
//attached fields | |
$wrapper->field_custom_field->set('value'); | |
//Save | |
$wrapper->save(); | |
//dpm($entity); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment