Implements hook_install().
function entity_test_install() {
// Auto-create a field for testing.
$field = array(
'field_name' => 'field_test_text',
'type' => 'text',
'cardinality' => 1,
'translatable' => FALSE,
);
field_create_field($field);
$entity_types = array(
'entity_test',
'entity_test_rev',
'entity_test_mul',
'entity_test_mulrev',
);
foreach ($entity_types as $entity_type) {
$instance = array(
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
'bundle' => $entity_type,
'label' => 'Test text-field',
);
field_create_instance($instance);
entity_get_form_display($entity_type, $entity_type, 'default')
->setComponent('field_test_text', array(
'type' => 'text_text',
))
->save();
}
}