You are here

function _content_admin_field_remove_submit in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 5 content_admin.inc \_content_admin_field_remove_submit()

Remove a field from a content type.

File

includes/content.admin.inc, line 625
Administrative interface for content type creation.

Code

function _content_admin_field_remove_submit($form, &$form_state) {
  module_load_include('inc', 'content', 'includes/content.crud');
  $form_values = $form_state['values'];
  $type = content_types($form_values['type_name']);
  $field = $type['fields'][$form_values['field_name']];
  if ($type && $field && $form_values['confirm']) {
    if (content_field_instance_delete($form_values['field_name'], $form_values['type_name'])) {
      drupal_set_message(t('Removed field %field from %type.', array(
        '%field' => $field['widget']['label'],
        '%type' => $type['name'],
      )));
    }
    else {
      drupal_set_message(t('There was a problem deleting %field from %type.', array(
        '%field' => $field['widget']['label'],
        '%type' => $type['name'],
      )));
    }
    $form_state['redirect'] = 'admin/content/node-type/' . $type['url_str'] . '/fields';
  }
}