mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
FIX: allowed countries/states at SiteConfig
This commit is contained in:
parent
8e7f5c2671
commit
f54eec1802
@ -16,6 +16,8 @@ use SilverStripe\Forms\FieldList;
|
|||||||
use SilverStripe\Forms\TreeMultiselectField;
|
use SilverStripe\Forms\TreeMultiselectField;
|
||||||
use SilverStripe\Forms\DropdownField;
|
use SilverStripe\Forms\DropdownField;
|
||||||
use Symbiote\Addressable\Addressable;
|
use Symbiote\Addressable\Addressable;
|
||||||
|
use SilverStripe\SiteConfig\SiteConfig;
|
||||||
|
use SilverStripe\Core\Config\Config;
|
||||||
|
|
||||||
//use BetterBrief\GoogleMapField;
|
//use BetterBrief\GoogleMapField;
|
||||||
|
|
||||||
@ -107,11 +109,8 @@ class SiteConfigExtension extends DataExtension
|
|||||||
];
|
];
|
||||||
|
|
||||||
if (\class_exists(Addressable::class)) {
|
if (\class_exists(Addressable::class)) {
|
||||||
$addr = \singleton(Addressable::class);
|
|
||||||
|
|
||||||
|
|
||||||
$stateLabel = _t('Addressable.STATE', 'State');
|
$stateLabel = _t('Addressable.STATE', 'State');
|
||||||
$allowedStates = $addr->getAllowedStates();
|
$allowedStates = Config::inst()->get(SiteConfig::class, 'allowed_states');
|
||||||
if (count($allowedStates) >= 1) {
|
if (count($allowedStates) >= 1) {
|
||||||
// If allowed states are restricted, only allow those
|
// If allowed states are restricted, only allow those
|
||||||
$addrFields[] = DropdownField::create('State', $stateLabel, $allowedStates);
|
$addrFields[] = DropdownField::create('State', $stateLabel, $allowedStates);
|
||||||
@ -124,7 +123,7 @@ class SiteConfigExtension extends DataExtension
|
|||||||
$addrFields[] = DropdownField::create(
|
$addrFields[] = DropdownField::create(
|
||||||
'Country',
|
'Country',
|
||||||
_t('Addressable.COUNTRY', 'Country'),
|
_t('Addressable.COUNTRY', 'Country'),
|
||||||
$addr->getAllowedCountries()
|
Config::inst()->get(SiteConfig::class, 'allowed_countries')
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$addrFields[] = TextField::create('State');
|
$addrFields[] = TextField::create('State');
|
||||||
|
Loading…
Reference in New Issue
Block a user