You are here

function tablefield_update_7002 in TableField 7.2

Same name and namespace in other branches
  1. 7.3 tablefield.install \tablefield_update_7002()

Change default field_formatter name from 'default' to 'tablefield_default'.

File

./tablefield.install, line 92
Installation options for TableField.

Code

function tablefield_update_7002() {
  $fields = field_read_fields(array(
    'type' => 'tablefield',
  ));

  // Tablefield enabled but no tablefields.
  if (!is_array($fields) || !count($fields)) {
    return;
  }
  $instances = field_read_instances(array(
    'field_id' => array_keys($fields),
  ));
  foreach ($instances as $instance) {
    foreach ($instance['display'] as $d => $display) {
      if ($display['type'] == 'default') {
        $instance['display'][$d]['type'] = 'tablefield_default';
        field_update_instance($instance);
      }
    }
  }
}