Skip to content

Commit

Permalink
Update tenant selection in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr authored Sep 15, 2021
1 parent 154ae01 commit e2d46c8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/XeroSiteConfigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ public function updateCMSFields(FieldList $fields)
$fields->addFieldsToTab('Root.Xero', [
ReadonlyField::create('XeroAccessToken', 'Access token')
->setDescription(sprintf(
'<a href="%s">Link to a xero account</a>',
'<a href="%s" target="_blank">Link to a new xero account</a>',
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
)
]);
Expand Down

0 comments on commit e2d46c8

Please sign in to comment.