I'm not sure if it is a feature or a bug, as it is a very basic issue:
Create a content type with geofield, select Openlayers Map widget for it, enter a label and a help text for the field.
Add a new node of the content type.

Issue:
The field label and help text is not shown in the node edit form. Only the map with the generic hardcoded help text is shown:
opmw.jpg

Remarks:
If other widget (e.g. Lat/Lon) is used, then the field has a nice frame, label and help text:
ll.jpg

Location + Gmap input field is presented with such a frame, label and user help text.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dan_man’s picture

If it is of any help - I ended up hacking the function openlayers_geofield_widget_afterbuild:

 ...  
   if (isset($element['#description'])){
     $element['geofield_openlayers_map_desc'] = array(
           '#markup' => '<div class="description geofield-help">' . $element['#description'] . '</div>'
     );
   }

Not ideal though....

gagarine’s picture

Issue summary: View changes

The element #title is their in the afterbuild function. I don't get why is not rendered. Perhaps the used theme function is wrong...

arx-e’s picture

I met this issue today and I implemented the hack offered by dan_man in #1 and it is working.
I just pasted the code after line 294 in the geofield.widgets.openlayers.inc file.

Any chance of this issue being addressed?

squarecandy’s picture

+1
I'm also experiencing this. Will try to make a patch after I explore more...

squarecandy’s picture

Here's what i came up with, based on @dan_man's edits…

/**
 * Callback for afterbuild for widget for js addition to
 */
function openlayers_geofield_widget_afterbuild($element, &$form_state) {

  $markup = '<div class="form-item geofield-openlayers-map" style="display:block">';
  if (isset($element['#title'])) {
    $markup .= '<label>'.$element['#title'].'</label>';
  }
  if (isset($element['#description']) && !empty($element['#description'])) {
    $markup .= '<div class="description geofield-help">' . $element['#description'] . '</div>';
  }
  else {
    $markup .= t('<div class="description geofield-help">Use the icons to select what type of feature to draw. Each map can contain one simple feature. Pan and zoom with arrows and the zoom bar.</div>');
  }
  $markup .= openlayers_geofield_form_latlon_map(array(), $element['#openlayers_mapname']);
  $markup .= '</div>';
  
  $element['geofield_openlayers_map'] = array('#markup' => $markup);

  drupal_add_js(
    array(
      'geofield' => array(
        'widget_settings' => $element['#widget_settings'],
      ),
    ),
    'setting'
  );

  return $element;
}

will roll into a patch in a moment.

squarecandy’s picture

Status: Active » Needs review
FileSize
1.75 KB

Here is a patch for this issue.

genebobmiller’s picture

Patch in #6 solved this issue for me,
also solves issue https://www.drupal.org/node/1791984.

sano’s picture

The patch was failing on the latest dev. build. Attached is a re-roll, that includes a minor change where html tags were extracted from a translatable string.