When a form returns a formstate error the following notice is returned.

Notice: Undefined index: #parents in Drupal\Core\Form\FormState->getError() (line 1112 of core/lib/Drupal/Core/Form/FormState.php).
Drupal\Core\Form\FormState->getError(Array) (Line: 160)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 120)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 120)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 120)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 120)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object) (Line: 23)
Drupal\Core\Form\FormErrorHandler->handleFormErrors(Array, Object) (Line: 202)

I did some quick research and found that it has to do with the following lines within the class GeofieldMap under Drupal\geofield_map\Element

// Geoaddress Field Settings.
    $complete_form[$element['#geoaddress_field']['field']]['widget'][0]['value']['#description'] = (string) t('This value will be synchronized with the Geofield Map Reverse-Geocoded value.');
    if ($element['#geoaddress_field']['hidden']) {
      $complete_form[$element['#geoaddress_field']['field']]['#attributes']['class'][] = 'geofield_map_geoaddress_field_hidden';
    }
    if ($element['#geoaddress_field']['disabled']) {
      $complete_form[$element['#geoaddress_field']['field']]['widget'][0]['value']['#attributes']['readonly'] = 'readonly';
      $complete_form[$element['#geoaddress_field']['field']]['widget'][0]['value']['#description'] = (string) t('This field is readonly. It will be synchronized with the Geofield Map Reverse-Geocoded value.');

    }
    // Ensure the geoaddress_field has got an #id, otherwise generate it.
    if (!isset($complete_form[$element['#geoaddress_field']['field']]['widget'][0]['value']['#id'])) {
      $complete_form[$element['#geoaddress_field']['field']]['widget'][0]['value']['#id'] = $element['#geoaddress_field']['field'] . '-0';
    }
CommentFileSizeAuthor
#2 notice_undefined-2886430-2.patch3.61 KBitamair

Comments

IJsbrandy created an issue. See original summary.

itamair’s picture

StatusFileSize
new3.61 KB

Tnx @IJsbrandy ... I was unable to recreate the error message, but probably found the matter.
Check if the attached patch solves your issue, and confirm it, please, so that II will commit it in the dev branch.

itamair’s picture

Status: Active » Patch (to be ported)
itamair’s picture

Status: Patch (to be ported) » Needs review

  • itamair committed d0d7706 on 8.x-1.x
    Applied patch "notice_undefined-2886430-2.patch" (Issue #2886430: Notice...
itamair’s picture

Status: Needs review » Fixed
ijsbrandy’s picture

Thank you @itamair it fixes the issue!

itamair’s picture

Status: Fixed » Closed (fixed)