i have this error when insert new content with tablefield.

Notice: Undefined offset: 0 in tablefield_field_validate() (line 95 of /var/www/drupal-7.0/sites/all/modules/tablefield/tablefield.module).
Notice: Undefined offset: 0 in tablefield_field_validate() (line 95 of /var/www/drupal-7.0/sites/all/modules/tablefield/tablefield.module).
Notice: Undefined index: array_parents in field_default_form_errors() (line 343 of /var/www/drupal-7.0/modules/field/field.form.inc).
Recoverable fatal error: Argument 2 passed to drupal_array_get_nested_value() must be an array, null given, called in /var/www/drupal-7.0/modules/field/field.form.inc on line 343 and defined in drupal_array_get_nested_value() (line 6253 of /var/www/drupal-7.0/includes/common.inc).

Comments

pippopeppe’s picture

I have solved this bug with this code(line 91):

......
function tablefield_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
    drupal_add_css(drupal_get_path('module', 'tablefield') . '/tablefield.css');
    // Catch empty form submissions for required tablefields
    //I HAVE ADDED CONTROL FOR ITEMS ARRAY
    if (count($items)) {
        if ($instance['required'] && tablefield_field_is_empty($items[0], $field)) {
            $message = t('@field is a required field.', array('@field' => $instance['label']));
            $errors[$field['field_name']][$langcode][0]['tablefield'][] = array(
                'error' => 'empty_required_tablefield',
                'message' => $message,
            );
        }
    }
}
....
rogical’s picture

Good, but can you post a patch?

Creating patches: http://drupal.org/patch/create

mauriziopinotti’s picture

here's a quick patch:

--- tablefield.module.orig	2011-11-27 18:31:24.965682476 +0100
+++ tablefield.module	2011-11-27 18:32:16.105681335 +0100
@@ -96,7 +96,7 @@
 function tablefield_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
   drupal_add_css(drupal_get_path('module', 'tablefield') . '/tablefield.css');
   // Catch empty form submissions for required tablefields
-  if ($instance['required'] && tablefield_field_is_empty($items[0], $field)) {
+  if ($instance['required'] && count($items) && tablefield_field_is_empty($items[0], $field)) {
     $message = t('@field is a required field.', array('@field' => $instance['label']));
     $errors[$field['field_name']][$langcode][0]['tablefield'][] = array(
       'error' => 'empty_required_tablefield',
jenlampton’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

This is a very old issue, if the problem persists please reopen.