Skip to content

Commit

Permalink
Merge pull request #75 from niondigital/master
Browse files Browse the repository at this point in the history
Fixed Google Maps dependency in Craft 4
  • Loading branch information
leevigraham committed Oct 10, 2023
2 parents 1249214 + 6715b03 commit 643217f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/fields/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getTableAttributeHtml(mixed $value, ElementInterface $element):

return "<pre>$value</pre>";
}

public function getInputHtml(mixed $value, ?ElementInterface $element = null): string
{
Craft::$app->getView()->registerAssetBundle(AddressFieldAsset::class);
Expand Down Expand Up @@ -192,7 +192,8 @@ private function renderFieldJs()
'defer' => '',
'position' => View::POS_END,
'depends' => [AddressFieldAsset::class],
]
],
'googleMapsPlaces'
);
}

Expand All @@ -202,7 +203,7 @@ private function renderAddressFields($value): string
$id = Html::id($this->handle);
$namespace = Craft::$app->getView()->getNamespace();
$namespacedId = Craft::$app->getView()->namespaceInputId($id);

$countryCode = $value ? $value->getCountryCode() : $this->defaultCountryCode;

if (empty($countryCode)) {
Expand Down Expand Up @@ -351,7 +352,7 @@ protected function getFieldLabels(AddressFormat $addressFormat): array

return $labels;
}

public function getCountryOptions(): array
{
$countryRepository = new CountryRepository();
Expand All @@ -366,7 +367,7 @@ public function getCountryOptions(): array

return $options;
}

private function getSubdivisionOptions($countryCode, $parentId = null): array
{
if (!$countryCode) {
Expand All @@ -391,7 +392,7 @@ private function getSubdivisionOptions($countryCode, $parentId = null): array

return $options;
}

public function normalizeValue(mixed $value, ?ElementInterface $element = null): mixed
{
/**
Expand All @@ -418,7 +419,7 @@ public function normalizeValue(mixed $value, ?ElementInterface $element = null):

return null;
}

public function serializeValue(mixed $value, ?ElementInterface $element = null): mixed
{
if (empty($value)) {
Expand Down

0 comments on commit 643217f

Please sign in to comment.