My use case:
Step 1: I have a tablefield defined with 2 columns and 9 rows where the top row is the header and the first column has defined default values, therefore presenting the end user with the ability to enter values for those pre-defined options:
(ignore the third column in the above image, as it shouldn't be there for the purposes of this example)
Step 2: As a regular user: I edit this field (wherever it may be- user/node etc.) and save my entries in the second column. So far so good.
Step 3: As an admin: I then go to edit the field settings (for the tablefield created in Step 1) to add another default value in the first column (by rebuilding the table with an additional row and entering the default value in column 1, row 10) and save the form.
Step 4: As a regular user: I return to edit the field and I can't see the newly created default value in column 1, row 10, because the widget form is 'rationalized' from the saved data. From this unserialized/rationalised data, the number of rows and columns are calculated for rebuilding the form.
This is not always the intended behaviour, especially when the rebuild table options are set to be excluded for the end user.
Therefore, my workaround is to provide a instance level option to allow site builders to say whether the values for cols/rows defined in the default value should always be respected. On the field settings form it looks like this:
When the widget form gets built, and this option is set, then the rows/cols values (part of the default values rebuild options in the field settings form) get used as the basis for the size of the tablefield to build.
This works for my use case, but will likely still need to be tested in the cases of ajax, field collection and the other more advanced use cases this module should support. I'm putting this out there for feedback and review. Marking as feature request, as this may not technically be a bug in what the intended functionality has been to date. That said, it causes issues with my use case, which may not be all that common. It would be good to know if anyone else has come across this quirk of the module to date. I couldn't find any directly related issues in the queue.
Patch to follow.
Comments
Comment #1
Barry_Fisher CreditAttribution: Barry_Fisher commentedPatch as per Original Post
Comment #2
Barry_Fisher CreditAttribution: Barry_Fisher commentedComment #3
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedThe patch probably could use a reroll against the latest dev.
Comment #4
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedComment #5
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedReroll removing the extra added option as it seems to be better covered by a combination of existing settings. The idea of using the widget settings however led to a new feature request: #2863947: Move options from TABLE FIELD SETTINGS to widget instance SETTINGS.
The rebuild restrict option now acts as follows. Avoids the number of cols/rows being changed by content editors. For all users if in combination with locked cells. Only for users without the permission "rebuild tablefield" in other cases. This way also the superuser (uid=1) will see the content tables changed with new default values. This removes the ability also for this user to add/delete rows/cols for an individual table. They can still do it on the field settings (default). This is most likely the intention of a table with both restricted rebuild permissions and locked header. It's better to have the same behavior for all users in that case.
The patch still solves the original issue making added default values visible when editing existing content. It furthermore adds option descriptions.
Comment #7
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedComment #8
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedDoes also act on tables that don't have locked cells. Might be due to changes made in other issues as it was tested. To check.
Comment #9
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedComment #11
lolandese CreditAttribution: lolandese at HCL Technologies Limited commented