Problem/Motivation

Error notice when saving the form that lets a widget be selected.

    Notice: Undefined index: widget_type in field_ui_widget_type_form_submit() (line 752 of core/modules/field_ui/field_ui.admin.inc).
    Notice: Undefined index: module in field_ui_widget_type_form_submit() (line 753 of core/modules/field_ui/field_ui.admin.inc).
    Notice: Undefined index: widget_type in field_ui_widget_type_form_submit() (line 755 of core/modules/field_ui/field_ui.admin.inc).
    Notice: Undefined index: module in _field_write_instance() (line 615 of core/modules/field/field.crud.inc).
    Notice: Undefined index: in Drupal\field_ui\FieldOverview->form() (line 143 of core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php).

Steps to reproduce

  1. Go to the manage fields tab of a content type like article, admin/structure/types/manage/article/fields
  2. edit a field (like tags) and pick the widget type tab (or click on the widget link from the manage fields table), admin/structure/types/manage/article/fields/field_tags/widget-type
  3. save it ("continue") button
  4. see error, and the widget is gone from the field row in the manage fields table

Proposed resolution

(description of the proposed solution, the rationale behind it, and workarounds for people who cannot use the patch)

Remaining tasks

  • write test exposing bug
  • propose solutions
  • write initial patch
  • review
  • update patch
  • repeat

User interface changes

No UI changes anticipated.

API changes

No API changes anticipated.

Related

Found while trying to add a widget setting #1120144: Term Reference Autocomplete widget - add option to match only start of term and expose settings (size, match)

Files: 
CommentFileSizeAuthor
#5 field_ui_widget-1872786-5-test-only.patch2.32 KByched
FAILED: [[SimpleTest]]: [MySQL] 49,731 pass(es), 6 fail(s), and 0 exception(s).
[ View ]
#5 field_ui_widget-1872786-5.patch3.29 KByched
PASSED: [[SimpleTest]]: [MySQL] 49,658 pass(es).
[ View ]
#1 widget-s01-2012-12-22_1347.png99.78 KBYesCT
#1 widget-s02-2012-12-22_1348.png40.33 KBYesCT
#1 widget-s03-2012-12-22_1349.png167.64 KBYesCT

Comments

Following the steps to reproduce (it has errors for any field and widget)

1. Go to the manage fields tab of a content type like article, admin/structure/types/manage/article/fields

widget-s01-2012-12-22_1347.png

2. edit a field (like tags) and pick the widget type tab (or click on the widget link from the manage fields table), admin/structure/types/manage/article/fields/field_tags/widget-type

widget-s02-2012-12-22_1348.png

3. save it ("continue") button

    Notice: Undefined index: widget_type in field_ui_widget_type_form_submit() (line 752 of core/modules/field_ui/field_ui.admin.inc).
    Notice: Undefined index: module in field_ui_widget_type_form_submit() (line 753 of core/modules/field_ui/field_ui.admin.inc).
    Notice: Undefined index: widget_type in field_ui_widget_type_form_submit() (line 755 of core/modules/field_ui/field_ui.admin.inc).
    Notice: Undefined index: module in _field_write_instance() (line 615 of core/modules/field/field.crud.inc).
    Notice: Undefined index: in Drupal\field_ui\FieldOverview->form() (line 143 of core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php).

4. see error, and the widget is gone from the field row in the manage fields table

widget-s03-2012-12-22_1349.png

Issue summary:View changes

Updated issue summary with steps to reproduce

Title:Saving a widget type choice leads to error noticesCan't change widget types
Priority:Normal» Critical

Ran into this while testing #501428: Date and time field type in core.

Since you can't change widget types at all, I believe this is a critical bug.

Assigned:Unassigned» yched

On it.

Status:Active» Needs review
StatusFileSize
new3.29 KB
PASSED: [[SimpleTest]]: [MySQL] 49,658 pass(es).
[ View ]
new2.32 KB
FAILED: [[SimpleTest]]: [MySQL] 49,731 pass(es), 6 fail(s), and 0 exception(s).
[ View ]

This was caused by this hunk in #552604: Adding new fields leads to a confusing "Field settings" form :

@@ -656,8 +716,7 @@ function field_ui_widget_type_form($form, &$form_state, FieldInstance $instance)
   );
   $form['basic'] = array(
-    '#type' => 'details',
-    '#title' => t('Change widget'),
+    '#tree' => TRUE,
   );
   $form['basic']['widget_type'] = array(
     '#type' => 'select',

which changed the structure of the submitted $form_state['values'].
This 'basic' element was there to support a fieldset originally, but if the fieldset is gone, we don't need the 'basic' level at all.

Patch removes it, and adds tests for this "change widget type" UI.
(patch also removes a couple vars that are not actually used)

Status:Needs review» Reviewed & tested by the community

The patch looks good, fixes the issue and is test covered. RTBC :)

Status:Reviewed & tested by the community» Fixed

Excellent. :) Thanks a lot, both for the fix and for the tests!

Committed and pushed to 8.x.

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

Issue summary:View changes

Updated issue summary with notice messages