When using the select list widget type for fields such as taxonomies, the following error is encountered:
Fatal error: [] operator not supported for strings in /var/www/*/sites/all/modules/contrib/prepopulate/src/Controller/prepopulateController.php on line 51
In Drupal 8, the select list field may be populated with merely the following URL argument: node/add/content_type?edit[field_name]=92
As opposed to the method given in the documentation for Drupal 7 which is as follows:
Taxonomy fields with widget type select list and term ID:
http://www.example.com/node/add/node?edit[field_ch_projekt_2][und]=92
As we no longer pass the [und] along to the prepopulate module, it is unnecessary to pass an empty array key on line 51 of prepopulateController.php
So we change line 51 from this: $form['widget']['#value'][] = $request_slice;
To simply this: $form['widget']['#value'] = $request_slice;
I have tested the patch and it has resolved the issue for me.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | fixing-select-list-2712529-1.patch | 530 bytes | rich_dawson |
Comments
Comment #2
rich_dawson commentedComment #3
rich_dawson commentedComment #4
walkingdexter commentedGood patch, works for me.
Comment #5
juliencarnot commentedFix tested by WalkingDexter, MrVee on related issue, and me...
Comment #7
jbrauer commentedCommitted. Thanks.