Geofield Openlayers field formatter returns a field even if it has no data

Created on 12 February 2013, almost 12 years ago
Updated 13 May 2023, over 1 year ago

This causes an empty label and container to be rendered even if there is no map.

This is because it still returns a full elements array even if there are no items in it. Small patch attached that fixes this.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Paul Lomax

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Fixed over 1 year ago
  • πŸ‡ΈπŸ‡°Slovakia poker10

    Shouldn't this be expanded over all formatter types?

    No, because all other formatters fills the $element array in foreach cycles, therefore it is populated only if $items is not an empty array. This one formatter does populate the $element array directly without the check.

    See:

        case 'geofield_openlayers':
          $map_name = $display['settings']['map_preset'] ? $display['settings']['map_preset'] : 'geofield_formatter_map';
          $element[0] = array('#markup' => _geofield_openlayers_formatter($map_name, $items));
          return $element;
    

    vs:

        case 'geofield_def_list':
          foreach ($items as $delta => $item) {
            $element[$delta] = array('#markup' => _geofield_def_list_formatter($item, $display['settings']));
          }
          return $element;
    

    I think the patch is correct. Committed this, thanks all!

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

Production build 0.71.5 2024