Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Invalid argument supplied for foreach() in taxonomy_field_widget_form() when embedding a file entity that has a a term reference field.
Steps to reproduce
In the WYSIWYG, embed a file with terms associated with it.
Edit the File
Or if you just embed a file without any tags, the error appears.
Comment | File | Size | Author |
---|---|---|---|
#13 | term_reference_fields-2062365-13.patch | 2.59 KB | brockfanning |
|
Comments
Comment #1
bneil CreditAttribution: bneil commentedFile fields also are having a problem: #2062681: File fields are not being handled correctly when file is embedded in the WYSIWYG
Comment #2
jvandyk CreditAttribution: jvandyk commentedThis is happening because when media.format_form.js line 48 sets the initial value for the Tag field, it doesn't understand that the Tag field is actually a multiple value field, not just a regular text field. Therefore, if there is no value in the field, it says, duh, I'll set this to an empty string value in the string that is generated for the filter, instead of an empty array.
Should be:
This error cascades all the way down through many layers until Taxonomy ultimately complains about it.
Comment #3
mirzu CreditAttribution: mirzu commentedAdded an issue to track the fix for this: #2062721: Add a white list of file fields that can be overwritten when the file is added in the wysiwyg
Comment #4
Dave ReidMarking as a duplicate of #2062721: Add a white list of file fields that can be overwritten when the file is added in the wysiwyg
Comment #5
vegantriathleteThis is not actually a duplicate. The referenced issue has a patch that just creates the whitelist. Whether Term reference is selected in the whitelist or not it does not appear as a field in the media browser for an image embedded via the wysiwyg.
The point of this issue to add the capability to override term references properly, not just to get rid of the error by not allowing the term references to be overridden.
Comment #6
vegantriathleteComment #7
Devin Carlson CreditAttribution: Devin Carlson commentedComment #8
Dave ReidComment #9
brockfanning CreditAttribution: brockfanning commentedThis patch fixes the issue in the cases that I've tested, which are: single value fields of the types: term reference, entityreference, checkbox, and list (integers, strings, etc.). I suspect that it may not work with autocomplete widgets, but I have not tested that.
Comment #10
brockfanning CreditAttribution: brockfanning commentedI should clarify: #9 above only works for single-value fields.
Comment #11
brockfanning CreditAttribution: brockfanning commentedHmm, #9 may not be working. Let me investigate some more.
Comment #12
brockfanning CreditAttribution: brockfanning commentedFalse alarm, I guess something else was going on. Switching back to needs-reivew.
Comment #13
brockfanning CreditAttribution: brockfanning commentedI haven't tested it too much, but here is a slight expansion to support multi-value fields, at least for select lists.
Comment #14
brockfanning CreditAttribution: brockfanning commentedComment #16
joseph.olstadcommitted to dev 7.x-2.x