I have a few custom markers and a custom marker field on a taxonomy. Whenever I save the taxonomy the marker is saved correctly, and works in all displays. This is a non-issue. HOWEVER, when I go to edit the term, the marker list always shows "-None-" instead of my custom marker. Any help is appreciated. I can make changes in the module myself but a little direction is always helpful! Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joegl created an issue. See original summary.

joegl’s picture

I'm not sure if this is the correct way to do it and in fact, it probably isn't. HOWEVER, I have modified the code in the file gmap/gmap_fields/gmap_fields.module starting at line 69:

/**
 * Implements hook_field_widget_form_alter().
 */
function gmap_fields_field_widget_form_alter(&$element, &$form_state, $context) {  
  if ($context['field']['type'] == GMAP_FIELDS_TYPE_MARKER) {
    $element['#options'] += gmap_get_marker_titles();
    $element["#default_value"] = _gmap_fields_default_field_value($context);
  }
}

/**
 * Get the default value helper function
 */
function _gmap_fields_default_field_value($context) {
  if(isset($context['delta'])) {
    $delta = $context['delta'];
    return $context['items'][$delta]['value'];
  }
  return NULL;
}

It works for me but that's only when the field is limited to one value, but that's solving my issue at the moment. I will probably have to alter it later.

tnathanjames’s picture

Joegl, thanks for the issue and the code example.

I looked at a couple other examples of contrib modules implementing hook_field_widget_form_alter. It looks like it is more common to use a ternary operator instead of a separate function. Here is a patch that does the same as the code above.

tnathanjames’s picture

Version: 7.x-2.10 » 7.x-2.x-dev
Category: Support request » Bug report
Status: Active » Needs review
joegl’s picture

Thanks Nathan!

00trav’s picture

I had the same issue. I can confirm the patch works correctly.

TommyChris’s picture

#3 works!

l0ke’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, pretty obvious patch. RTBC

serpforge’s picture

#3 help for me, thanks!
But, why the module is not patched?

TommyChris’s picture

Please commit #3!

  • podarok committed 11b55e9 on 3.0.x
    Issue #2651206 by tnathanjames: GMAP Marker Field always defaults to...
podarok’s picture

Version: 7.x-2.x-dev » 3.0.x-dev
Status: Reviewed & tested by the community » Fixed

#3 is merged
thnx

  • podarok committed 11b55e9 on 7.x-2.x
    Issue #2651206 by tnathanjames: GMAP Marker Field always defaults to...

Status: Fixed » Closed (fixed)

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