Skip to content

Instantly share code, notes, and snippets.

@kristianb21
Created March 10, 2015 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristianb21/e7006da999cb0bf2ef86 to your computer and use it in GitHub Desktop.
Save kristianb21/e7006da999cb0bf2ef86 to your computer and use it in GitHub Desktop.
PHP-D7-Create Entity
$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