Skip to content

Commit 036acaa

Browse files
committed
Fix formatting for postcode, readonly presentation of address
1 parent ccf066c commit 036acaa

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

javascript/addressfinder_ent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
for (var i = 1; i <= 6; i++) {
4545
manual.find('input[name*=PostalLine' + i + ']').val(item['postal_line_' + i] || '')
4646
}
47-
47+
console.log(item);
4848
manual.find('input[name*=Suburb]').val(item.suburb || '')
4949
manual.find('input[name*=City]').val(item.city || '')
5050
manual.find('input[name*=Postcode]').val(item.postcode || '')

src/AddressFinderField.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class AddressFinderField extends TextField
4040
*/
4141
private $manualToggle;
4242

43+
private static $api_key = false;
44+
45+
private static $include_address_finder_js = true;
46+
4347
/**
4448
* @param string $name
4549
* @param string $title
@@ -48,6 +52,7 @@ class AddressFinderField extends TextField
4852
public function __construct($name, $title = null, $value = null)
4953
{
5054
$this->addressField = new TextField("{$name}[Address]", $title);
55+
$this->addressField->setAttribute('autocomplete', 'off');
5156
$this->manualToggle = new HiddenField("{$name}[ManualAddress]");
5257
$this->manualFields = new FieldList();
5358

@@ -78,11 +83,13 @@ public function __construct($name, $title = null, $value = null)
7883
_t("AddressFinderField.CITY", "City")
7984
));
8085

81-
$this->manualFields->push(new NumericField(
86+
$this->manualFields->push($postcode = new NumericField(
8287
"{$name}[Postcode]",
8388
_t("AddressFinderField.POSTCODE", "Postcode")
8489
));
8590

91+
$postcode->setHTML5(true);
92+
8693
$this->setFieldHolderTemplate('Includes/AddressFinderField_holder');
8794

8895
parent::__construct($name, $title, $value);
@@ -136,7 +143,10 @@ public function performReadonlyTransformation()
136143
$readonly->push($field->performReadonlyTransformation());
137144
}
138145

146+
$this->addressField = $this->addressField->performReadonlyTransformation();
139147
$this->manualFields = $readonly;
148+
149+
return clone $this;
140150
}
141151

142152
/**
@@ -161,12 +171,13 @@ public function setDisabled($bool)
161171
public function FieldHolder($properties = array())
162172
{
163173
Requirements::javascript('//api.addressfinder.io/assets/v3/widget.js');
164-
Requirements::javascript(ADMIN_THIRDPARTY_DIR . '/jquery/jquery.js');
165174

166175
if(Controller::curr()->hasMethod('ShowSwitchView')) {
167176
// leftandmain check. If admin then use entwine.
168177
} else {
169-
Requirements::javascript('addressfinder/javascript/addressfinder.js');
178+
if(Config::inst()->get(AddressFinderField::class, 'include_address_finder_js')) {
179+
Requirements::javascript('addressfinder/javascript/addressfinder.js');
180+
}
170181
}
171182

172183
$properties = array(

0 commit comments

Comments
 (0)