You are here

function content_field_basic_form_submit in Content Construction Kit (CCK) 6.3

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

Create a new field for a content type.

1 string reference to 'content_field_basic_form_submit'
content_field_basic_form in includes/content.admin.inc
A form element for selecting field, widget, and label.

File

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

Code

function content_field_basic_form_submit($form, &$form_state) {
  $form_values = $form_state['values'];
  $label = $form_values['label'];

  // Set the right module information
  $field_types = _content_field_types();
  $widget_types = _content_widget_types();
  $form_values['module'] = $field_types[$form_values['type']]['module'];
  $form_values['widget_module'] = $widget_types[$form_values['widget_type']]['module'];

  // Make sure we retain previous values and only over-write changed values.
  module_load_include('inc', 'content', 'includes/content.crud');
  $instances = content_field_instance_read(array(
    'field_name' => $form_values['field_name'],
    'type_name' => $form_values['type_name'],
  ));
  $field = array_merge(content_field_instance_collapse($instances[0]), $form_values);
  if (content_field_instance_update($field)) {
    drupal_set_message(t('Updated basic settings for field %label.', array(
      '%label' => $label,
    )));
  }
  else {
    drupal_set_message(t('There was a problem updating the basic settings for field %label.', array(
      '%label' => $label,
    )));
  }
  $type = content_types($form_values['type_name']);
  $form_state['redirect'] = 'admin/content/node-type/' . $type['url_str'] . '/fields/' . $form_values['field_name'];
  $form_state['rebuild'] = FALSE;
}