From e2d46c8bf62a551e5d2498cf464e4789bfe47ab6 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Thu, 16 Sep 2021 11:50:20 +1200 Subject: [PATCH] Update tenant selection in admin --- src/XeroSiteConfigExtension.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/XeroSiteConfigExtension.php b/src/XeroSiteConfigExtension.php index d26e347..436baba 100644 --- a/src/XeroSiteConfigExtension.php +++ b/src/XeroSiteConfigExtension.php @@ -30,23 +30,23 @@ public function updateCMSFields(FieldList $fields) $fields->addFieldsToTab('Root.Xero', [ ReadonlyField::create('XeroAccessToken', 'Access token') ->setDescription(sprintf( - 'Link to a xero account', + 'Link to a new xero account', XeroFactory::singleton()->getRedirectUri() )) ]); if ($this->owner->XeroAccessToken) { - $provider = XeroFactory::singleton()->getProvider(); $tenants = []; + $tenantRecords = XeroFactory::singleton()->getTenants($this->owner->XeroAccessToken); - foreach ($provider->getTenants($this->owner->XeroAccessToken) as $tenant) { - $tenants[$tenant->id] = $tenant->name; + foreach ($tenantRecords as $tenant) { + $tenants[$tenant->id] = $tenant->tenantName; } $fields->addFieldsToTab('Root.Xero', [ DropdownField::create( 'XeroTenantId', - 'XeroTenantId', + 'Xero Tenant', $tenants ) ]);