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)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

YesCT’s picture

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

YesCT’s picture

Issue summary: View changes

Updated issue summary with steps to reproduce

YesCT’s picture

webchick’s picture

Title: Saving a widget type choice leads to error notices » Can'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.

yched’s picture

Assigned: Unassigned » yched

On it.

yched’s picture

Status: Active » Needs review
FileSize
3.29 KB
2.32 KB

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)

plach’s picture

Status: Needs review » Reviewed & tested by the community

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

webchick’s picture

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.

Anonymous’s picture

Issue summary: View changes

Updated issue summary with notice messages