Dynamic Crosstab Form Input

Problem: Using Yii 2, I need to build a form that captures tabular data with user-defined dynamic lists of row headers and column headers.

Table 1 is a user-specified list of variable length:

A

B

C

D

Table 2 is also a user-specified list of variable length:

W

X

Y

Z

As part of data collection, we need a tabular form that is a matrix or CROSS of Tables A & B, using the values from Table A and B as row and column headers respectively.

|W|X|Y|Z|

A|0|0|0|0|

B|0|0|0|0|

C|0|0|0|0|

D|0|0|0|0|

Table 3 would store the results as a long list of (length of A x length of B) rows and cell values. The rows for this would be generated by a CROSS query and inserted prior to the tabular form being filled by the user.

id,row,col,cellvalue

1,A,W,0

2,A,X,0

3,A,Y,0

4,A,Z,0

5,B,W,0

6,B,X,0

7,B,Y,0

8,B,Z,0

9,C,W,0

10,C,X,0

11,C,Y,0

12,C,Z,0

13,D,W,0

14,D,X,0

15,D,Y,0

16,D,Z,0

I have previously solved this problem using a PHP REST (Slim) + JavaScript (YUI 3) prototype. In it I use JS to retrieve tables 1 & 2 & 3 via REST, and then use nested loops to pivot the data of table 3 and populate an editable data table widget that uses Table 1 as row headers, Table 2 as column headers, and Table 3 as the corresponding initial cell value for each. When a cell value changes I write back to a REST route something like /table3/A/W/<value>.

The prototype works well enough but I have decided that a backend built on Yii 2 is the way to go for the actual product. I am new to Yii and also to the MVC paradigm. Based on a little experimentation and consulting the documentation it seems like each of M, V & C need to have static row and column names. Unfortunately with my problem the rows AND columns are dynamic. I think something like kartik-v’s tabularform or dynagrid extensions could get me part of the way, but how can I overcome the hurdle of needing the rows and columns to be dynamically defined rather than static? If this is not possible with these extensions am I looking at making my own widgets to accomplish this?

Any hints or suggestions would be most welcome.

Thank you,

Chris