Problem/Motivation

I inherited a project where there is a form on a map but the page is rendered before the form is submitted.

It would be great to check and provide a default empty value for the `geolocation_geocoder_address` if it's empty, so that PHP doesn't display warnings.

The Google Maps provider seems to be fine with an empty value, but ymmv for other providers.

Steps to reproduce

Embed a map on a page that has not submitted the form yet.

Proposed resolution

Check to see that the form value exists before using its value.

Remaining tasks

Patch incoming.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dzinkevich created an issue. See original summary.

dzinkevich’s picture

rishabjasrotia made their first commit to this issue’s fork.

christianadamski’s picture

Status: Active » Needs work

Why not simply

    $location_data = $this->geocoderManager
      ->getGeocoder($settings['plugin_id'], $settings['settings'])
      ->geocode($form_value['geocoder']['geolocation_geocoder_address'] ?? '');

instead? Would be cleared and less verbose? Does it work for you?

rishabjasrotia’s picture

@christianadamski
Thank you for the simplification. Implemented the new changes.

rishabjasrotia’s picture

Status: Needs work » Needs review
christianadamski’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

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