You are here

function field_tools_field_delete_form_submit in Field tools 7

Same name and namespace in other branches
  1. 8 field_tools.admin.inc \field_tools_field_delete_form_submit()

Submit handler for deleting multiple instances.

File

./field_tools.admin.inc, line 521
Contains admin callbacks for the Field tools module.

Code

function field_tools_field_delete_form_submit($form, &$form_state) {
  $field = $form_state['build_info']['args'][0];
  foreach (array_filter($form_state['values']['instances']) as $instance_key) {
    list($entity_type, $bundle_name) = explode(':', $instance_key);
    $instance = field_info_instance($entity_type, $field['field_name'], $bundle_name);
    field_delete_instance($instance);
    drupal_set_message(t('Deleted instance of %fieldname from %entity bundle %bundle', array(
      '%fieldname' => $field['field_name'],
      '%entity' => $entity_type,
      '%bundle' => $bundle_name,
    )));
  }

  // Redirect the user to the overview page.
  $form_state['redirect'] = 'admin/reports/fields/tools';
}