After adding a proximity field to a view with a Geolocation Google Maps API - CommonMap formatter and adding a proximity sort criteria with an exposed geolocation form, the following PHP notice is shown on the resulting view page:

Notice: Undefined index: #weight in Drupal\geolocation\Plugin\views\field\ProximityField->viewsForm() (line 540 of modules/contrib/geolocation/src/Plugin/views/field/ProximityField.php).

This is caused by a faulty if condition in ProximityField.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dietr_ch created an issue. See original summary.

dietr_ch’s picture

Attached a patch that replaces empty() with isset() to check whether the weight is present on the form field.

dietr_ch’s picture

Status: Active » Needs review

  • dietr_ch authored db8af13 on 8.x-1.x
    Issue #2862522 by dietr_ch: Notice: Undefined index: #weight in...
ChristianAdamski’s picture

Status: Needs review » Fixed

Thanks

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

lindaweb’s picture

Component: Google Maps geolocation » Geolocation Field / Backend

Patch Failed : #1 FAILED at 536

should be

     foreach (Element::children($form) as $key) {
-      if (empty($form[$key]['#weight'])) {
+      if (isset($child[$key]['#weight'])) {
         $form[$key]['#weight'] = $form[$key]['#weight'] - 2;
       }
       else {