1 field_group.field_ui.inc field_group_format_type_form_submit($form, &$form_state)

Form submission handler for field_group_format_type_form().

File

core/modules/field_group/field_group.field_ui.inc, line 1101
Field_group.field_ui.inc is a file that contains most functions needed on the Fields UI Manage forms (display and fields).

Code

function field_group_format_type_form_submit($form, &$form_state) {
  $form_values = $form_state['values'];
  $group = $form['#group'];
  $mode = $group->mode;
  $original_format_type = $group->format_type;
  if ($original_format_type == $form_values['type']) {
    backdrop_set_message(t('The chosen format type is the same as the original. No changes made.'));
    return;
  }

  $original_formatter_settings = $group->format_settings;
  $group->format_type = $form_values['type'];
  $group->format_settings = _field_group_get_default_formatter_settings($group->format_type, $mode);
  // If the format type is changed, make sure we carry over the unique
  // changes such as classes, ids.
  $group->format_settings['instance_settings'] = _field_group_preserve_shared_instance_settings($group->format_settings['instance_settings'], $original_formatter_settings['instance_settings'], $group);

  try {
    field_group_group_save($group, FALSE);
    backdrop_set_message(t('Changed the format type for group %label.', array('%label' => $group->group_name)));
  }
  catch (Exception $e) {
    backdrop_set_message(t('There was a problem changing the format type for group %label.', array('%label' => $group->group_name)), 'error');
  }

  cache_clear_all('field_groups', 'cache_field');
}