Problem/Motivation

When using the module to update field data, not all changes are saved.

Steps to reproduce

  1. Create an entity reference field (such as a taxonomy term).
  2. Set the field to use autocomplete
  3. Create an entity reference field (such as a taxonomy term).
  4. Set the field to use a select list
  5. Bulk update field content for a node that uses those fields
  6. Change the values of both
  7. Only the autocomplete change is saved

Proposed resolution

Investigate how field data is processed -- likely the `target_id` of the widget.
Ensure proper handling of select fields.

Note that this may solve https://www.drupal.org/project/bulk_update_fields/issues/3363620 and https://www.drupal.org/project/bulk_update_fields/issues/3185661 as well.

Remaining tasks

Find the problem
Fix the problem
Time permitting, write a test

User interface changes

None

API changes

None

Data model changes

None

Comments

agentrickard created an issue. See original summary.

agentrickard’s picture

Here's the form data for the two types.

Autocomplete:

field_name
  widget
    0
      target_id
  	  value

Select:

field_name
  widget
    #key_column => target_id
    value	  		 
agentrickard’s picture

Status: Active » Needs review
StatusFileSize
new52.97 KB
new1008 bytes

I tracked this down to a mismatch in the default_value_input and form input values. (See attached screenshot).

This patch fixed it for me, but I suspect there may be a better fix, perhaps in this part of `buildForm`:

              else {
                // TODO
                // I cannot figure out how to get a form element for only a
                // field. Maybe someone else can.
                // TODO Doing it this way does not allow for feild labels on
                // textarea widgets.
                $form[$field_name] = $entity->get($field_name)->defaultValuesForm($temp_form_element, $temp_form_state);
              }

Other parts of this IF/ELSE set the field value, but know what widget they are targetting

$form['default_value_input'][$field_name] = ....