How does drupal widget and formatter functions know about the field types defined in the 'hook_field_info()'? For example, I have the following 'hook_field_info()':

function dimfield_field_info() {
  return array (
    'dimensions' => array(
      'label' => t('Dimensions'),
      'description' => t('This field stores a height and width, and depth.'),
      'settings' => array('num_dimensions' => 2),
      'instance_settings' => array(
        'max_height' => 0,
        'max_width' => 0,
        'max_depth' => 0,
      ),
      'default_widget' => 'dimfield_combined',
      'default_formatter' => 'dimfield_default',
    ),
  );
}

Then, I have the following hook_field_formatter_info():

function dimfield_field_formatter_info() {
  return array (
    'dimfield_default' => array(
      'label' => t('Default'),
      'field types' => array('dimensions'),
    ),
    'dimfield_table' => array(
      'label' => t('Show as table'),
      'field types' => array('dimensions'),
      'settings' => array('units_as' => 'column',
    ),
  );
}

How does 'dimfield_field_formatter_info() > dimfield_{default|table} > field types' know about 'dimensions' from dimfield_field_info() -- is there 'corresponding core function' that translates this?

Comments

Not sure what the question

Not sure what the question is.

'field types' => array('dimensions'),

defines which field type(s) the formatter works with. The field types are defined with field API.

I'm just curious: where in core (function / file) is the line

'field types' => array('dimensions'),

allow formatters to use the respective field type(s)?

It's easy to find this on

It's easy to find this on your own.

Go to the documentation of hook_field_formatter_info().

Click on the link that reads "1 invocation of hook_field_formatter_info()" and follow the link to the function that invokes it.

Start reading the code. In this case, look for the line that reads:

<?php
$formatter_types
= (array) module_invoke($module, 'field_formatter_info');
?>

...and go from there.

--
www.ztwistbooks.com. Math books that are actually fun.