function field_tools_field_delete_form_submit in Field tools 8
Same name and namespace in other branches
- 7 field_tools.admin.inc \field_tools_field_delete_form_submit()
Submit handler for deleting multiple instances.
File
- ./
field_tools.admin.inc, line 522 - NOTICE: THIS FILE IS OBSOLETE. IT IS BEING KEPT UNTIL ALL FUNCTIONALITY IS PORTED TO DRUPAL 8.
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::messenger()
->addMessage(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';
}