@@ -40,6 +40,10 @@ class AddressFinderField extends TextField
40
40
*/
41
41
private $ manualToggle ;
42
42
43
+ private static $ api_key = false ;
44
+
45
+ private static $ include_address_finder_js = true ;
46
+
43
47
/**
44
48
* @param string $name
45
49
* @param string $title
@@ -48,6 +52,7 @@ class AddressFinderField extends TextField
48
52
public function __construct ($ name , $ title = null , $ value = null )
49
53
{
50
54
$ this ->addressField = new TextField ("{$ name }[Address] " , $ title );
55
+ $ this ->addressField ->setAttribute ('autocomplete ' , 'off ' );
51
56
$ this ->manualToggle = new HiddenField ("{$ name }[ManualAddress] " );
52
57
$ this ->manualFields = new FieldList ();
53
58
@@ -78,11 +83,13 @@ public function __construct($name, $title = null, $value = null)
78
83
_t ("AddressFinderField.CITY " , "City " )
79
84
));
80
85
81
- $ this ->manualFields ->push (new NumericField (
86
+ $ this ->manualFields ->push ($ postcode = new NumericField (
82
87
"{$ name }[Postcode] " ,
83
88
_t ("AddressFinderField.POSTCODE " , "Postcode " )
84
89
));
85
90
91
+ $ postcode ->setHTML5 (true );
92
+
86
93
$ this ->setFieldHolderTemplate ('Includes/AddressFinderField_holder ' );
87
94
88
95
parent ::__construct ($ name , $ title , $ value );
@@ -136,7 +143,10 @@ public function performReadonlyTransformation()
136
143
$ readonly ->push ($ field ->performReadonlyTransformation ());
137
144
}
138
145
146
+ $ this ->addressField = $ this ->addressField ->performReadonlyTransformation ();
139
147
$ this ->manualFields = $ readonly ;
148
+
149
+ return clone $ this ;
140
150
}
141
151
142
152
/**
@@ -161,12 +171,13 @@ public function setDisabled($bool)
161
171
public function FieldHolder ($ properties = array ())
162
172
{
163
173
Requirements::javascript ('//api.addressfinder.io/assets/v3/widget.js ' );
164
- Requirements::javascript (ADMIN_THIRDPARTY_DIR . '/jquery/jquery.js ' );
165
174
166
175
if (Controller::curr ()->hasMethod ('ShowSwitchView ' )) {
167
176
// leftandmain check. If admin then use entwine.
168
177
} 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
+ }
170
181
}
171
182
172
183
$ properties = array (
0 commit comments