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.
Bug found for tablefield 7.x-2.2:
When implementing table field in an unlimited field format for a node, any programmatic call to load the existing node renders only the first tablefield child with the formatted 'tabledata' property.
This appears to be due to an issue of the hook_field_load functionality only expecting one value ($table[0]).
I haven't committed a patch to a public project before, but I believe the following resolves the issue by allowing multiple table $values with tablefield_rationalize_table() functionality, and would love some help verifying the adoption:
/**
* Implements hook_field_load().
*/
function tablefield_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
foreach ($items as $delta => $table) {
foreach($table as $id=>$field){
if (isset($field['value'])) {
$items[$delta][$id]['tabledata'] = tablefield_rationalize_table(unserialize($field['value']));
}
}
}
}
Comment | File | Size | Author |
---|---|---|---|
#2 | tablefield-multiple_values-2193163-2.patch | 849 bytes | jenlampton |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedI applied this "patch" and it solved a problem with multiple setting and using entity translation. I also applied the patch from https://www.drupal.org/node/2231009.
Now tablefield works for me as expected!
Comment #2
jenlamptonNice work on your first fix @mark_schaal !!!
I've created a patch out of the recommended fix, along with some formatting cleanup. Here in Drupal-land we use two spaces for indentation, and we put lots of spaces in the foreaches for better legibility. Take a look at the patch file if you are curious about the cleanup.
Comment #4
jenlamptonThis fix will go into the next release for tablefield.