Steps to reproduce:

  1. Create a vocabulary with two terms and one field, with data in that field for each term
  2. From Administer >> Content Management >> Taxonomy >> List Terms
  3. Change the order of the terms by using the drag and drop.
  4. Click Save to save the change

Results:

The data in most, if not all, terms in the vocabulary will have been erased (even back to the table).

Possible Solution:

After some tracking, I discovered in term_fields.module the term_fields_taxonomy function , on line 185, the following:

foreach ($fids as $fid) {
	$value = $form_values[$fid];
	if (!is_array($value)) {
		$values[$fid] = $value;
	}
	else {
		// this is a date field
		$values[$fid] = $value['year'] . '-' . $value['month'] . '-' . $value['day'];
	}
}

When you change the weight of the term using the drag and drop, it doesn't submit the full forms for the terms, and the $form_values variable is empty.
Therefore, when it is processed by the afore mentioned code, all of the form_values that are now missing which include the field data have the value set to null.

I was able to correct the issue as far as I can see by changing it to the following:

foreach ($fids as $fid) {
    //Check for the values passed through form_values
    if(array_key_exists($fid, $form_values)){
        $value = $form_values[$fid];
    }
    //If they are not there, pull them from the saved values.
    else{
        $value = term_fields_get_field($tid, $fid);
    }

    if (!is_array($value)) {
        $values[$fid] = $value;
    }
    else {
        // this is a date field
        $values[$fid] = $value['year'] . '-' . $value['month'] . '-' . $value['day'];
    }
}

Now it will allow changing the weight using the list without erasing data, and changing field data within the term still works fine.

I wanted to help out seeing how much hassle this module saved me. :)

Comments

archard’s picture

Status: Active » Fixed

Hi, thanks a lot for the bug report. This is fixed in the latest dev version. Please test it out and make sure everything works as expected.

Status: Fixed » Closed (fixed)

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