FIX: allowed countries/states at SiteConfig

This commit is contained in:
Tony Air 2022-06-15 22:12:38 +02:00
parent 8e7f5c2671
commit f54eec1802
1 changed files with 4 additions and 5 deletions

View File

@ -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');