1
1
<?php
2
2
3
+ use SilverStripe \Forms \TextField ;
4
+
3
5
/**
4
6
* A wrapper for the AddressFinder API.
5
7
*
6
8
* Standard layout is a simple text field with the required javascript events,
7
- * but as per best practices (http://addressfinder.co.nz/docs/best_practices)
8
- * this FormField also provides fallback fields in case the user cannot find
9
+ * but as per best practices (http://addressfinder.co.nz/docs/best_practices)
10
+ * this FormField also provides fallback fields in case the user cannot find
9
11
* their address
10
12
*
11
13
* @package addressfinder
@@ -39,7 +41,7 @@ public function __construct($name, $title = null, $value = null)
39
41
$ this ->addressField = new TextField ("{$ name }[Address] " , $ title );
40
42
$ this ->manualToggle = new HiddenField ("{$ name }[ManualAddress] " );
41
43
$ this ->manualFields = new FieldList ();
42
-
44
+
43
45
44
46
for ($ i = 1 ; $ i < 4 ; $ i ++) {
45
47
$ this ->manualFields ->push (new TextField (
@@ -156,7 +158,7 @@ public function FieldHolder($properties = array())
156
158
157
159
return parent ::FieldHolder ($ properties );
158
160
}
159
-
161
+
160
162
/**
161
163
* @return FieldList
162
164
*/
@@ -203,23 +205,23 @@ public function setValue($value, $record = null)
203
205
$ this ->addressField ->setValue ($ value );
204
206
}
205
207
}
206
-
208
+
207
209
/**
208
- * @param DataObjectInterface
210
+ * @param SilverStripe\ORM\ DataObjectInterface
209
211
*/
210
- public function saveInto (DataObjectInterface $ object )
212
+ public function saveInto (SilverStripe \ ORM \ DataObjectInterface $ record )
211
213
{
212
- $ object ->{$ this ->getName ()} = $ this ->addressField ->Value ();
214
+ $ record ->{$ this ->getName ()} = $ this ->addressField ->Value ();
213
215
214
216
foreach ($ this ->getManualFields () as $ field ) {
215
217
$ fieldName = $ this ->getNestedFieldName ($ field );
216
218
217
- $ object ->{$ fieldName } = $ field ->Value ();
219
+ $ record ->{$ fieldName } = $ field ->Value ();
218
220
}
219
221
}
220
222
221
223
/**
222
- * Returns the actual name of a child field without the prefix of this
224
+ * Returns the actual name of a child field without the prefix of this
223
225
* field.
224
226
*
225
227
* @param FormField $field
@@ -230,7 +232,7 @@ protected function getNestedFieldName($field)
230
232
{
231
233
return substr ($ field ->getName (), strlen ($ this ->getName ()) + 1 , -1 );
232
234
}
233
-
235
+
234
236
/**
235
237
* @param string $name
236
238
*
@@ -254,7 +256,7 @@ public function setName($name)
254
256
/**
255
257
* If this field is required then we require at least the first postal line
256
258
* along with the town and postcode. Either this has been manually filled
257
- * in or, automatically filled in by
259
+ * in or, automatically filled in by
258
260
*
259
261
* @param Validator $validator
260
262
*
@@ -278,7 +280,7 @@ public function validate($validator)
278
280
'PostalLine1 ' ,
279
281
false
280
282
);
281
-
283
+
282
284
return false ;
283
285
}
284
286
@@ -291,7 +293,7 @@ public function validate($validator)
291
293
"City " ,
292
294
false
293
295
);
294
-
296
+
295
297
return false ;
296
298
}
297
299
@@ -304,7 +306,7 @@ public function validate($validator)
304
306
"Postcode " ,
305
307
false
306
308
);
307
-
309
+
308
310
return false ;
309
311
}
310
312
}
0 commit comments