1 field_ui.admin.inc field_ui_field_delete_form($form, &$form_state, $instance)

Form constructor for removing a field instance from a bundle.

See also

field_ui_menu()

field_ui_field_delete_form_submit()

Related topics

File

core/modules/field_ui/field_ui.admin.inc, line 1795
Admin page callbacks for the Field UI module.

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' => $instance['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 (!empty($field['locked'])) {
    unset($output['actions']['submit']);
    $output['description']['#markup'] = t('This field is <strong>locked</strong> and cannot be deleted.');
  }

  return $output;
}