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'] = '
' . 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, &$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.
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_state, $instance) { $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) { @@ -1970,12 +1912,6 @@ function field_ui_field_edit_form_validate($form, &$form_state) { */ function field_ui_field_edit_form_submit($form, &$form_state) { $instance = $form_state['values']['instance']; - $field = $form_state['values']['field']; - - // Update any field settings that have changed. - $field_source = field_info_field($instance['field_name']); - $field = array_merge($field_source, $field); - field_update_field($field); // Handle the default value. if (isset($form['instance']['default_value_widget'])) { diff --git modules/file/tests/file.test modules/file/tests/file.test index 18a914c..e59129d 100644 --- modules/file/tests/file.test +++ modules/file/tests/file.test @@ -477,7 +477,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // Change the field setting to make its files private, and upload a file. $edit = array('field[settings][uri_scheme]' => 'private'); - $this->drupalPost("admin/structure/types/manage/$type_name/fields/$field_name", $edit, t('Save settings')); + $this->drupalPost("admin/structure/types/manage/$type_name/fields/$field_name/field-settings", $edit, t('Save field settings')); $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; @@ -489,12 +489,12 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // Ensure we can't change 'uri_scheme' field settings while there are some // entities with uploaded files. - $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name"); + $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name/field-settings"); $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', t('Upload destination setting disabled.')); // Delete node and confirm that setting could be changed. node_delete($nid); - $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name"); + $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name/field-settings"); $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', t('Upload destination setting enabled.')); } diff --git modules/image/image.test modules/image/image.test index 483f9fa..70e0b4a 100644 --- modules/image/image.test +++ modules/image/image.test @@ -785,7 +785,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase { $edit = array( 'files[field_settings_default_image]' => drupal_realpath($images[0]->uri), ); - $this->drupalPost('admin/structure/types/manage/article/fields/' . $field_name, $edit, t('Save settings')); + $this->drupalPost("admin/structure/types/manage/article/fields/$field_name/field-settings", $edit, t('Save field settings')); // Clear field info cache so the new default image is detected. field_info_cache_clear(); $field = field_info_field($field_name); @@ -810,7 +810,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase { $edit = array( 'field[settings][default_image][fid]' => 0, ); - $this->drupalPost('admin/structure/types/manage/article/fields/' . $field_name, $edit, t('Save settings')); + $this->drupalPost("admin/structure/types/manage/article/fields/$field_name/field-settings", $edit, t('Save field settings')); // Clear field info cache so the new default image is detected. field_info_cache_clear(); $field = field_info_field($field_name);