The Google Map formatter needs to clear the tokens if the field/source is empty and a replacement can't be found.
/Plugin/FIeld/FieldFormatter/GeolocationGoogleMapFormatter.php
Line 212:
- $content = \Drupal::token()->replace($settings['info_text'], $token_context, ['callback' => [$this, 'geolocationItemTokens']]);
+ $content = \Drupal::token()->replace($settings['info_text'], $token_context, ['callback' => [$this, 'geolocationItemTokens'], 'clear' => TRUE]);
API: Token::replace
Also the returned token replacements need to passed to the theme layer as a render array otherwise the output will display markup as a string,
/Plugin/FIeld/FieldFormatter/GeolocationGoogleMapFormatter.php
Line 214:
$content = \Drupal::token()->replace($settings['info_text'], $token_context, ['callback' => [$this, 'geolocationItemTokens'], 'clear' => TRUE]);
+ $content = \Drupal\Core\Render\Markup::create($content);
Sorry I would supply a patch but I'm unlikely to create it cleanly.
Comments
Comment #2
dkre commentedComment #3
dkre commentedComment #4
christianadamski commentedHey @dkre,
thanks for this, good point!
- Added clears where token::replace is used.
- Markup will only return a string itself, plus its marked as @internal. So I won't add that part, unless you have a really good reason why.
Comment #6
christianadamski commentedThanks!