doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 10 forks source link

{{ address.multiline() }} not working #119

Closed CreateSean closed 2 weeks ago

CreateSean commented 3 months ago

Craft: 5.3.6 Google Maps: 5.0.2

I have this code which is not outputting the address as expected

      {% set address = entry.address %}
      {% if entry.address %}
        <dt class="text-sm font-semibold tracking-wider uppercase text-greenBrand-light">Address</dt>
        <dd class="mb-6 text-xl">
          {{ address.multiline() }}
        </dd>
      {% endif %}

I then did a {{ dump(address) }} and can see the fake address I put in the field.

doublesecretagency\googlemaps\models\Address {#2696 ▼
  -_events: []
  -_eventWildcards: []
  -_behaviors: null
  -_errors: null
  -_validators: null
  -_scenario: "default"
  +lat: null
  +lng: null
  +id: null
  +elementId: 305
  +fieldId: 42
  +formatted: null
  +raw: null
  +name: null
  +street1: "100 Yonge Street"
  +street2: null
  +city: "Toronto"
  +state: "Ontario"
  +zip: "M5C 2W1"
  +neighborhood: null
  +county: null
  +country: "Canada"
  +countryCode: null
  +placeId: null
  +distance: null
  +zoom: 13
  +enabledSubfields: []
}

Please advise

lindseydiloreto commented 2 months ago

multiline is a method which takes several things into account when rendering. You won't gain much by dumping the whole address, that's a red herring.

What are you expecting to see in your output? What are you seeing instead?

CreateSean commented 2 months ago

@lindseydiloreto I was expecting {{ address.multiline() }} to output the full address as it is in the entry field.

lindseydiloreto commented 2 weeks ago

You may have been expecting something closer to the formatted value. For more info, read these docs about the difference between multiline and formatted...

https://plugins.doublesecretagency.com/google-maps/models/address-model/#multiline-vs-formatted

Hope that helps! 🙂