-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Change adding countries to backend field
Due to some problems with instantiating domain models the country field needs to be changed to an input. This caused the itemProcFunc to not be called anymore. Adding a FormDataProvider for the country selection fixes this.
- Loading branch information
Showing
6 changed files
with
77 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is developed by evoWeb. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Evoweb\StoreFinder\Form\FormDataGroup; | ||
|
||
use TYPO3\CMS\Backend\Form\FormDataProvider\AbstractItemProvider; | ||
use TYPO3\CMS\Backend\Form\FormDataProviderInterface; | ||
use TYPO3\CMS\Core\Country\CountryProvider; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* A data provider group for casual database records | ||
*/ | ||
class LocationCountryItems extends AbstractItemProvider implements FormDataProviderInterface | ||
{ | ||
public function addData(array $result): array | ||
{ | ||
$table = $result['tableName']; | ||
|
||
if ($table === 'tx_storefinder_domain_model_location') { | ||
$fieldName = ''; | ||
|
||
/** @var CountryProvider $countryProvider */ | ||
$countryProvider = null; | ||
foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) { | ||
if ($fieldName !== 'country') { | ||
continue; | ||
} elseif ($countryProvider === null) { | ||
$countryProvider = GeneralUtility::makeInstance(CountryProvider::class); | ||
} | ||
|
||
foreach ($countryProvider->getAll() as $country) { | ||
$result['processedTca']['columns']['country']['config']['items'][] = [ | ||
'label' => $country->getLocalizedNameLabel(), | ||
'value' => $country->getAlpha2IsoCode(), | ||
]; | ||
} | ||
} | ||
|
||
$result['processedTca']['columns']['country']['config']['items'] = $this->translateLabels( | ||
$result, | ||
$result['processedTca']['columns']['country']['config']['items'], | ||
$table, | ||
$fieldName | ||
); | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters