Tablefild custom elements processor

Created on 12 May 2025, 25 days ago

Problem/Motivation

Tablefield module needs a special processor for nice data export. Currently the formatted processor returns:

"\u003Cdiv id=\"tablefield-wrapper-node-77-field_tablefield-0\" class=\"tablefield-wrapper\"\u003E\n\n\n\u003Cdiv class=\"layer-wrapper gin-layer-wrapper\"\u003E\n      \u003Ctable id=\"tablefield-node-77-field_tablefield-0\" class=\"tablefield\" data-striping=\"1\"\u003E\n      \n      \n      \n              \u003Ctbody\u003E\n                                  \u003Ctr class=\"odd\"\u003E\n                              \u003Ctd class=\"row_0 col_0\"\u003ERow 0 column 0\u003C/td\u003E\n                              \u003Ctd class=\"row_0 col_1\"\u003ERow 0, column 1\u003C/td\u003E\n                          \u003C/tr\u003E\n                                  \u003Ctr class=\"even\"\u003E\n                              \u003Ctd class=\"row_1 col_0\"\u003E7 row 1, col 0\u003C/td\u003E\n                              \u003Ctd class=\"row_1 col_1\"\u003ERow and column both 1\u003C/td\u003E\n                          \u003C/tr\u003E\n                                  \u003Ctr class=\"odd\"\u003E\n                              \u003Ctd class=\"row_2 col_0\"\u003Row 2 col 0 01/2026\u003C/td\u003E\n                              \u003Ctd class=\"row_2 col_1\"\u003row and col both 2 03/2027\u003C/td\u003E\n                          \u003C/tr\u003E\n                  \u003C/tbody\u003E\n                \u003C/table\u003E\n  \u003C/div\u003E\n\u003C/div\u003E",

The whole table is stored in the first value of the field so when retrieving the data, keep that in mind.

Proposed resolution

Create a new field processor

📌 Task
Status

Active

Version

3.0

Component

Code

Created by

🇸🇮Slovenia useernamee Ljubljana

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @useernamee
  • 🇸🇮Slovenia useernamee Ljubljana
  • 🇮🇳India ajayyadav

    I have not getting any such issue. I have installed module and export data in csv format.

    Exported table in csv

    0,heading1,heading2,heading3,heading4,
    1,heading11,heading12,heading13,heading14,
    2,heading21,heading22,heading23,heading24,
  • 🇸🇮Slovenia useernamee Ljubljana
  • 🇸🇮Slovenia useernamee Ljubljana

    @ajayyadav thank you for your response but when you render the field as custom elements there currently is no 'export as csv' option.

    Anyways I had to adjust the processor to support multivalue fields as well, so there's another level of nesting added, but the output I think works out.

  • Merge request !117Add tablefield processor. → (Merged) created by useernamee
  • 🇸🇮Slovenia useernamee Ljubljana
  • 🇸🇮Slovenia useernamee Ljubljana
  • 🇦🇹Austria fago Vienna

    Thx! I reviewed the PR and added some comments.
    I think we should also add a basic (kernel?) test which makes sure that the output is working as expected.

  • 🇸🇮Slovenia useernamee Ljubljana
  • 🇸🇮Slovenia useernamee Ljubljana

    I removed the label and added the kernel test which was passing locally. I was checking the CI and I think that tests are not running there.

    I was unsure about the header settings.

  • 🇦🇹Austria fago Vienna

    thank you, that looks pretty good!

    I've added one question about the output-data-structure above, could you check that and make sure it's good? Maybe it is, but it seems not.

    Besides that, it's great to see test-coverage here. I'd suggest to add a couple of cases though, so we cover the features of our formatter:
    - run once without custom-header and once with
    - set weights differently and make sure sorting is applied correctly

  • 🇸🇮Slovenia useernamee Ljubljana

    I added tests coverage for multi value fields - which explain the result structure and a small fix to the formatter code.

    The header formatter configuration is only there for the FE to know if it should style the first row/column as header. On field configuration there's additional setting called `ignore_table_header` which again still passes through the first row - the config option is only used to determine whether the field is empty if contains only the first row.

  • 🇦🇹Austria fago Vienna

    thank you for the clarifications and better test, this seems pretty good already.

    However, as commented above I think we shall still optimize for the 90% use-case to be better and keep that simple in the output, i.e. output only the single data value in the single case and avoid wrapping it in the multi-value data-structure when there are is only one value.

  • 🇸🇮Slovenia useernamee Ljubljana
  • 🇦🇹Austria fago Vienna
  • 🇸🇮Slovenia useernamee Ljubljana
  • Pipeline finished with Skipped
    16 days ago
    #502863
  • Pipeline finished with Skipped
    16 days ago
    #502866
  • Pipeline finished with Skipped
    16 days ago
    #502867
  • Pipeline finished with Skipped
    16 days ago
    #502868
  • 🇦🇹Austria fago Vienna

    Thank you, that looks great now. Output is very nice for single-value fields and decent for multi-value fields + comes with test coverage! merged!

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

Production build 0.71.5 2024