We're currently working on creating a few customizations to the TableField module, mainly in the UI. We'd like to add a few new properties (Vertical Gridlines, Horizontal Gridlines, Tagging Type). These are all company-specific needs, so we're thinking we could create a custom module and possibly extend the TableField widget and formatters to a couple of custom ones we'd create. From there, the goal would be to simply add these new properties within the existing $element[tablefield][rebuild] array. However, after several attempts, we can't seem to get the custom fields to appear. At this point, we're aware that we simply don't know the best approach to handle such a task. That said, we figured reaching out to the creators was the best approach. So a few questions:

1. What is the best approach to keep the current functionality of TableField, avoid creating a duplicate field type, add data to the the variables stack for Twig, and add form fields to the current Tablefield form?
2. Is there an event we could/should subscribe to for this?
3. Is this something we should just do in a hook form alter? If we go that route, how will the values be returned to the theme?
4. Should we be creating a separate field altogether and just extending your classes?
5. If creating custom widgets and formatters is the best route, what do we need to do in our custom widget and formatters to retain your original form element but add our own custom fields as well? (we've tried this one the most at this point, but must be doing something wrong as all 4 attempts failed).

Once we figure this out, we're planning on contributing some of these things back to the module itself. Things like draggable rows/columns, deletion of specific rows and specific columns, etc..

Sorry if this is not the correct place to post this. We're all very new to Drupal!

Thanks!!

Comments

chist01 created an issue.

lolandese’s picture

Hi Chris,

Be aware that many features in the 7.x-3.x branch are not in D8 yet. That might be some of the features you are seeking like dragable rows.

It might be worth to look at those issues first as some of them have already been worked on or are in Patch to be ported status, meaning you could probably reuse much of the code created for the D7 version.

I would be seriously interested to see if you run into any issues when trying to extend the Tablefield following the below-mentioned approaches. If so, it might be needed to refactor some of the code to make the field better extendible.

Please, provide your progress here and we will gladly assist.