I have 3 vocabularies and a content type with a "taxonomy term reference" field which reference one of this vocabularies.

I tried to generate and associate terms in this field but nothing seems happened.
After a few investigations, I found that the term was created in the wrong vocabulary.

The problem is in getTid() in RealisticDummyContentTermReferenceField.php :

- there is two foreach() imbricated which use the same variable name as the value
- the foreach() doesn't break when the vocabulary is found, so if the last vocabulary in the loop is not the one we want to create a term for, the term is created in the wrong vocabulary

CommentFileSizeAuthor
#2 realistic_dummy_content-2887396-2.patch1.12 KBnixou

Comments

Nixou created an issue. See original summary.

nixou’s picture

StatusFileSize
new1.12 KB

Attached is the patch which solved the problem.

I'm not sure it's perfect.

alberto56’s picture

Title: Taxonomy term reference field are not populated » Taxonomy term reference field not populated if more than one vocabulary

Thanks for the patch. I opened a pull request on Github to track this at https://github.com/dcycle/realistic_dummy_content/pull/9. The patch seems to work fine, however I needed to add quite a bit of code in order to have automated unit tests, as well as make the code work for Drupal 8 as well as Drupal 7, since the codebase is identical for both versions. The tests can be tracked at https://circleci.com/gh/dcycle/realistic_dummy_content/tree/2887396; this is currently failing probably due to coding standards.

  • alberto56 authored 1981e64 on 7.x-2.x
    Issue #2887396 by Nixou: Taxonomy term reference field not populated if...

  • alberto56 authored 1981e64 on 8.x-2.x
    Issue #2887396 by Nixou: Taxonomy term reference field not populated if...
alberto56’s picture

Status: Active » Fixed

Thanks again! This has been fixed in 7.x-2.0 and 8.x-2.0 which were just released.

Status: Fixed » Closed (fixed)

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