You are here

function field_group_update_7007 in Field Group 7

Id attributes are now a setting. This update will insert the old id in the setting so old markup doesn't get broken. If you don't want an attribute, you can delete them on the fieldgroup settings.

File

./field_group.install, line 351
Fieldgroup module install file.

Code

function field_group_update_7007() {
  ctools_include("export");

  // Migrate the field groups so they have a unique identifier.
  $field_groups = ctools_export_load_object("field_group");
  foreach ($field_groups as $row) {

    // These field group types have an ID setting to populate.
    $populate_id_setting = array(
      'html-element',
      'div',
      'html5',
      'fieldset',
      'tabs',
      'htabs',
      'accordion',
    );
    if (in_array($row->data['format_type'], $populate_id_setting)) {

      // If mode is default, we don't know what view mode it was. Take full then.
      $view_mode = $row->mode == 'default' ? 'full' : $row->mode;
      $id = $row->entity_type . '_' . $row->bundle . '_' . $view_mode . '_' . $row->group_name;
      $row->data['format_settings']['instance_settings']['id'] = $id;
    }
    if ($row->export_type == EXPORT_IN_CODE) {
      unset($row->id);
      drupal_write_record('field_group', $row);
    }
    else {
      drupal_write_record('field_group', $row, array(
        'id',
      ));
    }
  }

  // Clear drupal and static cache.
  field_group_info_groups(NULL, NULL, NULL, TRUE);
}