You are here

function content_field_remove_form_submit in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 includes/content.admin.inc \content_field_remove_form_submit()

Remove a field from a content type.

File

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

Code

function content_field_remove_form_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 ($field['locked']) {
    return;
  }
  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';
  }
}