field_ui_field_delete_form

Versions
7
field_ui_field_delete_form($form, &$form_state, $obj_type, $bundle, $instance)

Menu callback; present a form for removing a field from a content type.

Code

modules/field_ui/field_ui.admin.inc, line 963

<?php
function field_ui_field_delete_form($form, &$form_state, $obj_type, $bundle, $instance) {
  $bundle = field_extract_bundle($obj_type, $bundle);
  $field = field_info_field($instance['field_name']);
  $admin_path = _field_ui_bundle_admin_path($obj_type, $bundle);

  $form['object_type'] = array('#type' => 'value', '#value' => $obj_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;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.