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 error/warning seems to come when you don't have encoded a default value for the field.
Here is a patch
Comment | File | Size | Author |
---|---|---|---|
#3 | tablefield-error_if_no_default_value-2657074-3-7.x.patch | 743 bytes | DuneBL |
no_warning.patch | 569 bytes | DuneBL | |
Comments
Comment #2
vitalie CreditAttribution: vitalie commentedmerci DuneBL, good catch. I had to stop mid-way through the creation of a new tablefield in order to replicate this.
In any case, I did a bit of code refactor. Please review patch in https://www.drupal.org/node/2493563#comment-10936881, comment #9 of #2493563: Default value are missing when using tablefield in an embedded form via #ajax. That patch deleted the line involved here, but at the same time, your patch is kind of contained in line 525 of the new code resulting after applying refactoring patch. If you like, could you test it? You'll have to apply it against latest dev version though.
Comment #3
DuneBLI have added the patch #9 (from https://www.drupal.org/node/2493563#comment-10936881) but I still get a warning when I add a node with and empty table (and without default value defined for the tablefield).
This is not so easy to test as the warning appears only when this newly created node is saved the first time.
Here is a small patch to handle this. As a side note, there is no need to test isset($tabledata)) and !empty($tabledata); testing only !empty($tabledata) is enough.
Comment #4
vitalie CreditAttribution: vitalie commentedHmm, cannot reproduce. If the table is empty, then it should not get to line 406, as $items is an empty array and it never enters the foreach.
Comment #5
vitalie CreditAttribution: vitalie commentedComment #6
lolandese CreditAttribution: lolandese at HCL Technologies Limited commented