Follow up for #552604: Adding new fields leads to a confusing "Field settings" form

Problem/Motivation

A like like: "Body has no field settings." shows on the global field settings tab ... when there are settings there.

nosettings-s01-creation-2012-12-29_0259.png

Proposed resolution

None yet.

Remaining tasks

  • Figure out what that line really means or what it was intended for.
  • Propose a solution.
  • Implement the change, provide patch
  • review patch
  • A screenshot with the fix would be nice.

User interface changes

Not really.

API changes

No api changes anticipated.

Related issues

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

YesCT’s picture

The creation of the field and editing of the field settings is similar.

YesCT’s picture

Since #552604-99: Adding new fields leads to a confusing "Field settings" form added cardinality setting (to every field?)

@@ -572,7 +573,42 @@ function field_ui_field_settings_form($form, &$form_state, $instance) {
   // If so, prevent changes to the field settings.
   $has_data = field_has_data($field);
   if ($has_data) {
-    $form['field']['#description'] = '<div class="messages error">' . t('There is data for this field in the database. The field settings can no longer be changed.') . '</div>' . $form['field']['#description'];
+    $form['field']['#prefix'] = '<div class="messages error">' . t('There is data for this field in the database. The field settings can no longer be changed.') . '</div>' . $form['field']['#prefix'];
+  }
+
+  // Build the configurable field values.
+  $cardinality = $field['cardinality'];
+  $form['field']['container'] = array(
+    // We can't use the container element because it doesn't support the title
+    // or description properties.
+    '#type' => 'item',
+    '#field_prefix' => '<div class="container-inline">',
+    '#field_suffix' => '</div>',
+    '#title' => t('Maximum number of values users can enter'),
+  );

I think there are no fields that will appear to have no field settings. (All fields will at least have the cardinality setting.)

Here is the bit that adds the note about no field settings:

  // Add settings provided by the field module. The field module is
  // responsible for not returning settings that cannot be changed if
  // the field already has data.
  $form['field']['settings'] = array(
    '#weight' => 10,
  );
  $additions = module_invoke($field['module'], 'field_settings_form', $field, $instance, $has_data);
  if (is_array($additions)) {
    $form['field']['settings'] += $additions;
  }
  if (!element_children($form['field']['settings'])) {
    $form['field']['settings'] += array(
      '#markup' => '<p>' . t('%field has no field settings.', array('%field' => $instance['label'])) . '</p>',
    );
  }

so maybe it's really meaning... "has no field settings, added by the field module, that can be changed" ?

YesCT’s picture

Status: Active » Needs review
FileSize
754 bytes

If it's assumed that every field will be selected the number of allowed values (they will all have the cardinality setting)... then I think we can just take out the line that checks for no settings.

If someone can give steps to reproduce adding a field that has no global settings, please add the steps in a comment. :) I could not get one.

How would contrib control the cardinality setting being there or not? Could contrib provide a field or widget where it would not make sense to allow multiple values?

YesCT’s picture

Issue tags: -API change, -D8MI

Status: Needs review » Needs work
Issue tags: -Usability, -Fields in Core, -String freeze

The last submitted patch, drupal-has_no_field_settings-1876134-3.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
Issue tags: +Usability, +Fields in Core, +String freeze
tstoeckler’s picture

Yes, that looks correct. Could probably use a look-over by someone @yched-ish :-) for any edge cases that I didn't think of, where this sentence still makes sense. It seems absolutely senseless to me, in the current form.

yched’s picture

Status: Needs review » Reviewed & tested by the community

Agreed, displaying this message males no sense now, there will always be something on that screen, unless some module form_alters() the cardinality select out, in which case the UX WTF of an empty screen is that module's business.

YesCT’s picture

YesCT’s picture

catch’s picture

Status: Reviewed & tested by the community » Fixed

Looks great. Committed/pushed to 8.x.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary adding screenshot.