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',
      ),
    ),
  );
}

Project information

Releases