diff --git modules/field/modules/text/text.test modules/field/modules/text/text.test index a2003ee..f60e43d 100644 --- modules/field/modules/text/text.test +++ modules/field/modules/text/text.test @@ -470,7 +470,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { function testTextFieldFormatted() { // Make node body multiple. $edit = array('field[cardinality]' => -1); - $this->drupalPost('admin/structure/types/manage/article/fields/body', $edit, t('Save settings')); + $this->drupalPost('admin/structure/types/manage/article/fields/body/field-settings', $edit, t('Save field settings')); $this->drupalGet('node/add/article'); $this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), t('Body field cardinality set to multiple.')); diff --git modules/field_ui/field_ui.admin.inc modules/field_ui/field_ui.admin.inc index cd4b37f..dcf8bcf 100644 --- modules/field_ui/field_ui.admin.inc +++ modules/field_ui/field_ui.admin.inc @@ -772,6 +772,8 @@ function field_ui_field_overview_form_submit($form, &$form_state) { field_create_field($field); field_create_instance($instance); + // Always show the field settings step, as the cardinality needs 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_submit($form, &$form_state) { 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($form, &$form_state, $instance) { $form['field']['#description'] = '
' . $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, &$form_state, $instance) { $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, &$form_state, $instance) { 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, &$form_state, $instance) { '#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, &$form_state, $instance) { '#default_value' => !empty($instance['description']) ? $instance['description'] : '', '#rows' => 5, '#description' => t('Instructions to present to the user below this field on the editing form.' . 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 .= '