Hi,
I've created an entity 'artwork' which has some custom fields, such as 'title' and 'created', and some fields added by the field api. I've specified the custom fields using the following hook:
function artwork_field_extra_fields() {
$extra = array();
foreach(artwork_types() as $type) {
$extra['artwork'][$type->type] = array(
'form' => array(
'title' => array(
'label' => t('Title'),
'description' => t('The name of the artwork'),
'weight' => -5,
),
),
'display' => array(
'title' => array(
'label' => t('Title'),
'description' => t('The name of the artwork'),
'weight' => -5,
),
'created' => array(
'label' => t('Created'),
'description' => t('Created on'),
'weight' => -4,
),
),
);
}
return $extra;
}
function artwork_types() {
$types = &drupal_static(__FUNCTION__);
if (empty($types)) {
$types['painting'] = (object) array(
'type' => 'painting',
'name' => t('Painting'),
'description' => t('A picture made with paint.'),
);
$types['sculpture'] = (object) array(
'type' => 'sculpture',
'name' => t('Sculpture'),
'description' => t('A carving made out of stone or wood.'),
);
}