Index: modules/field_ui/field_ui.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.admin.inc,v retrieving revision 1.87 diff -u -p -r1.87 field_ui.admin.inc --- modules/field_ui/field_ui.admin.inc 30 Nov 2010 23:55:11 -0000 1.87 +++ modules/field_ui/field_ui.admin.inc 6 Dec 2010 07:58:01 -0000 @@ -772,6 +772,8 @@ function field_ui_field_overview_form_su field_create_field($field); field_create_instance($instance); + // Always show the field settings step, as the maximum number of values + // need to be configured for new fields. $destinations[] = $admin_path . '/fields/' . $field['field_name'] . '/field-settings'; $destinations[] = $admin_path . '/fields/' . $field['field_name']; @@ -804,7 +806,7 @@ function field_ui_field_overview_form_su try { field_create_instance($instance); - $destinations[] = $admin_path . '/fields/' . $instance['field_name'] . '/edit'; + $destinations[] = $admin_path . '/fields/' . $instance['field_name']; // Store new field information for any additional submit handlers. $form_state['fields_added']['_add_existing_field'] = $instance['field_name']; } @@ -1528,6 +1530,20 @@ function field_ui_field_settings_form($f $form['field']['#description'] = '
' . t('There is data for this field in the database. The field settings can no longer be changed.') . '
' . $form['field']['#description']; } + // Build the configurable field values. + $form['field']['cardinality'] = array( + '#type' => 'select', + '#title' => t('Maximum number of values users can enter'), + '#options' => drupal_map_assoc(range(1, 10)) + array(FIELD_CARDINALITY_UNLIMITED => t('Unlimited')), + '#default_value' => $field['cardinality'], + ); + if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) { + $form['field']['cardinality']['#description'] = t('%unlimited will provide an %add-more button so users can add as many values as they like.', array( + '%unlimited' => t('Unlimited'), + '%add-more' => t('Add another item'), + )); + } + // Build the non-configurable field values. $form['field']['field_name'] = array('#type' => 'value', '#value' => $field['field_name']); $form['field']['type'] = array('#type' => 'value', '#value' => $field['type']); @@ -1727,8 +1743,12 @@ function field_ui_field_edit_form($form, $bundle = $instance['bundle']; $entity_type = $instance['entity_type']; $field = field_info_field($instance['field_name']); + $bundles = field_info_bundles(); - drupal_set_title($instance['label']); + drupal_set_title(t('%instance settings for %bundle', array( + '%instance' => $instance['label'], + '%bundle' => $bundles[$entity_type][$bundle]['label'], + )), PASS_THROUGH); $form['#field'] = $field; $form['#instance'] = $instance; @@ -1740,22 +1760,11 @@ function field_ui_field_edit_form($form, return $form; } - $field_type = field_info_field_types($field['type']); $widget_type = field_info_widget_types($instance['widget']['type']); - $bundles = field_info_bundles(); // Create a form structure for the instance values. $form['instance'] = array( '#tree' => TRUE, - '#type' => 'fieldset', - '#title' => t('%type settings', array('%type' => $bundles[$entity_type][$bundle]['label'])), - '#description' => t('These settings apply only to the %field field when used in the %type type.', array( - '%field' => $instance['label'], - '%type' => $bundles[$entity_type][$bundle]['label'], - )), - // Ensure field_ui_field_edit_instance_pre_render() gets called in addition - // to, not instead of, the #pre_render function(s) needed by all fieldsets. - '#pre_render' => array_merge(array('field_ui_field_edit_instance_pre_render'), element_info_property('fieldset', '#pre_render', array())), ); // Build the non-configurable instance values. @@ -1782,13 +1791,11 @@ function field_ui_field_edit_form($form, '#title' => t('Label'), '#default_value' => !empty($instance['label']) ? $instance['label'] : $field['field_name'], '#required' => TRUE, - '#weight' => -20, ); $form['instance']['required'] = array( '#type' => 'checkbox', '#title' => t('Required field'), '#default_value' => !empty($instance['required']), - '#weight' => -10, ); $form['instance']['description'] = array( @@ -1797,7 +1804,6 @@ function field_ui_field_edit_form($form, '#default_value' => !empty($instance['description']) ? $instance['description'] : '', '#rows' => 5, '#description' => t('Instructions to present to the user below this field on the editing form.
Allowed HTML tags: @tags', array('@tags' => _field_filter_xss_display_allowed_tags())), - '#weight' => 0, ); // Build the widget component of the instance. @@ -1832,76 +1838,12 @@ function field_ui_field_edit_form($form, $form['instance']['default_value_widget'] = field_ui_default_value_widget($field, $instance, $form, $form_state); } - $has_data = field_has_data($field); - if ($has_data) { - $description = '

' . t('These settings apply to the %field field everywhere it is used. Because the field already has data, some settings can no longer be changed.', array('%field' => $instance['label'])) . '

'; - } - else { - $description = '

' . t('These settings apply to the %field field everywhere it is used.', array('%field' => $instance['label'])) . '

'; - } - - // Create a form structure for the field values. - $form['field'] = array( - '#type' => 'fieldset', - '#title' => t('%field field settings', array('%field' => $instance['label'])), - '#description' => $description, - '#tree' => TRUE, - ); - - // Build the configurable field values. - $description = t('Maximum number of values users can enter for this field.'); - if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) { - $description .= '
' . t("'Unlimited' will provide an 'Add more' button so the users can add as many values as they like."); - } - $form['field']['cardinality'] = array( - '#type' => 'select', - '#title' => t('Number of values'), - '#options' => array(FIELD_CARDINALITY_UNLIMITED => t('Unlimited')) + drupal_map_assoc(range(1, 10)), - '#default_value' => $field['cardinality'], - '#description' => $description, - ); - - // Add additional field type settings. The field type module is - // responsible for not returning settings that cannot be changed if - // the field already has data. - $additions = module_invoke($field['module'], 'field_settings_form', $field, $instance, $has_data); - if (is_array($additions)) { - $form['field']['settings'] = $additions; - } - $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save settings')); return $form; } /** - * Pre-render function for field instance settings. - * - * Combines the instance, widget, and other settings into a single fieldset so - * that elements within each group can be shown at different weights as if they - * all had the same parent. - */ -function field_ui_field_edit_instance_pre_render($element) { - // Merge the widget settings into the main form. - if (isset($element['widget']['settings'])) { - foreach (element_children($element['widget']['settings']) as $key) { - $element['widget_' . $key] = $element['widget']['settings'][$key]; - } - unset($element['widget']['settings']); - } - - // Merge the instance settings into the main form. - if (isset($element['settings'])) { - foreach (element_children($element['settings']) as $key) { - $element['instance_' . $key] = $element['settings'][$key]; - } - unset($element['settings']); - } - - return $element; -} - -/** * Build default value fieldset. */ function field_ui_default_value_widget($field, $instance, &$form, &$form_state) {