Field API helper
Component ID
996716
Component name
Field API helper
Component type
module
Component security advisory coverage
covered
Downloads
2077
Component created
Component changed
Component body
Field helper provides two additional install-time hooks for defining fields and instances as well as two functions to invoke the installation and uninstallation of those definitions.
The following is an example .install file for a module named "example".
/**
* Implements hook_install().
*/
function example_install() {
field_helper_install_all('example');
}
/**
* Implements hook_uninstall().
*/
function example_uninstall() {
field_helper_uninstall_all('example');
}
/**
* Implements hook_install_fields().
*/
function example_install_fields() {
return array(
'some_field' => array(
'field_name' => 'some_field',
'type' => 'text_long',
),
);
}
/**
* Implements hook_install_instances().
*/
function example_install_instances() {
$t = get_t();
return array(
'some_field' => array(
'entity_type' => 'node',
'bundle' => 'some_node_type',
'field_name' => 'some_field',
'label' => $t('Some field'),
'description' => $t('Some field description.'),
'widget' => array(
'type' => 'text_textarea',
),
),
);
}
