function field_ui_field_delete_form

field_ui_field_delete_form($form, &$form_state, $instance)

Form constructor for removing a field instance from a bundle.

See also

field_ui_field_delete_form_submit()

Related topics

File

modules/field_ui/field_ui.admin.inc, line 1730
Administrative interface for custom field type creation.

Code

function field_ui_field_delete_form($form, &$form_state, $instance) {
  $bundle = $instance['bundle'];
  $entity_type = $instance['entity_type'];
  $field = field_info_field($instance['field_name']);

  $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);

  $form['entity_type'] = array('#type' => 'value', '#value' => $entity_type);
  $form['bundle'] = array('#type' => 'value', '#value' => $bundle);
  $form['field_name'] = array('#type' => 'value', '#value' => $field['field_name']);

  $output = confirm_form($form, 
  t('Are you sure you want to delete the field %field?', array('%field' => $instance['label'])), 
  $admin_path . '/fields', 
  t('If you have any content left in this field, it will be lost. This action cannot be undone.'), 
  t('Delete'), t('Cancel'), 
  'confirm'
  );

  if ($field['locked']) {
    unset($output['actions']['submit']);
    $output['description']['#markup'] = t('This field is <strong>locked</strong> and cannot be deleted.');
  }

  return $output;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field_ui!field_ui.admin.inc/function/field_ui_field_delete_form/7.x