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.
This patch does two things.
First, adds an ID to the table element in the form, so that it's easier to point to using javascript.
Seconds, adds table headers to the top (A,B,C,D,...) and left side (1,2,3,4,...) and hides input field borders, so that the feel is more spreadsheet-like.
The grand purpose of this is that I need to get horizontally-resizable columns (as one project I'm coding will use TableField with moderate-length strings), and javascript libraries usually hook into thead to do their magic.
I'm aware that this patch is totally uncalled for and that it might not make it to mainline.
Comment | File | Size | Author |
---|---|---|---|
tablefield-spreadsheet.patch | 3.04 KB | ptaff | |
Comments
Comment #1
weseze CreditAttribution: weseze commentedI'd like to thank you for your patch. It was really useful for my project. You can find the patch of my project with your patch included in it at http://drupal.org/node/1094568
Comment #2
mauriziopinotti CreditAttribution: mauriziopinotti commentedA cleaner solution could be adding a custom format to tablefield, and defining it in our own module.
PROS: no modifications to tablefield module
CONS: the table header is not a "th" tag but a "td" with a bold font
HOWTO: my module is named "casaconvenienza" (so search and replace it with your module name), so I added a "Tabular View (vertical headers)" with hook_field_formatter_info():
then I defined my hook_field_formatter_view for the given formatter copying and slightly modifying the tablefield function:
This actually removes the table headers, then I put the "strong" font with CSS:
Comment #3
Liam MorlandDrupal 6 is no longer supported. If this issue still exists in later versions, please re-open and update the version.