Skip to content

Commit 99a4131

Browse files
committed
4.0 support
1 parent 659f0c1 commit 99a4131

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

code/formfields/AddressFinderField.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22

3+
use SilverStripe\Forms\TextField;
4+
35
/**
46
* A wrapper for the AddressFinder API.
57
*
68
* 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
911
* their address
1012
*
1113
* @package addressfinder
@@ -39,7 +41,7 @@ public function __construct($name, $title = null, $value = null)
3941
$this->addressField = new TextField("{$name}[Address]", $title);
4042
$this->manualToggle = new HiddenField("{$name}[ManualAddress]");
4143
$this->manualFields = new FieldList();
42-
44+
4345

4446
for ($i = 1; $i < 4; $i++) {
4547
$this->manualFields->push(new TextField(
@@ -156,7 +158,7 @@ public function FieldHolder($properties = array())
156158

157159
return parent::FieldHolder($properties);
158160
}
159-
161+
160162
/**
161163
* @return FieldList
162164
*/
@@ -203,23 +205,23 @@ public function setValue($value, $record = null)
203205
$this->addressField->setValue($value);
204206
}
205207
}
206-
208+
207209
/**
208-
* @param DataObjectInterface
210+
* @param SilverStripe\ORM\DataObjectInterface
209211
*/
210-
public function saveInto(DataObjectInterface $object)
212+
public function saveInto(SilverStripe\ORM\DataObjectInterface $record)
211213
{
212-
$object->{$this->getName()} = $this->addressField->Value();
214+
$record->{$this->getName()} = $this->addressField->Value();
213215

214216
foreach ($this->getManualFields() as $field) {
215217
$fieldName = $this->getNestedFieldName($field);
216218

217-
$object->{$fieldName} = $field->Value();
219+
$record->{$fieldName} = $field->Value();
218220
}
219221
}
220222

221223
/**
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
223225
* field.
224226
*
225227
* @param FormField $field
@@ -230,7 +232,7 @@ protected function getNestedFieldName($field)
230232
{
231233
return substr($field->getName(), strlen($this->getName()) + 1, -1);
232234
}
233-
235+
234236
/**
235237
* @param string $name
236238
*
@@ -254,7 +256,7 @@ public function setName($name)
254256
/**
255257
* If this field is required then we require at least the first postal line
256258
* 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
258260
*
259261
* @param Validator $validator
260262
*
@@ -278,7 +280,7 @@ public function validate($validator)
278280
'PostalLine1',
279281
false
280282
);
281-
283+
282284
return false;
283285
}
284286

@@ -291,7 +293,7 @@ public function validate($validator)
291293
"City",
292294
false
293295
);
294-
296+
295297
return false;
296298
}
297299

@@ -304,7 +306,7 @@ public function validate($validator)
304306
"Postcode",
305307
false
306308
);
307-
309+
308310
return false;
309311
}
310312
}

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "fullscreeninteractive/silverstripe-addressfinder",
33
"type": "silverstripe-module",
44
"description": "SilverStripe FormField for AddressFinder.co.nz",
5-
"keywords": ["silverstripe","form"],
5+
"keywords": ["silverstripe", "form"],
66
"homepage": "https://github.com/fullscreeninteractive/silverstripe-addressfinder",
77
"license": "BSD-3-Clause",
88
"authors": [{
@@ -11,9 +11,9 @@
1111
"homepage": "http://fullscreen.io"
1212
}],
1313
"extra": {
14-
"installer-name": "addressfinder"
14+
"installer-name": "addressfinder"
1515
},
1616
"require": {
17-
"silverstripe/framework": ">=3.1"
17+
"silverstripe/framework": "^4.0.*"
1818
}
19-
}
19+
}

0 commit comments

Comments
 (0)