diff --git a/_protected/app/system/core/forms/processing/CountryRestrictionCoreFormProcess.php b/_protected/app/system/core/forms/processing/CountryRestrictionCoreFormProcess.php index 67fb48bac5..66e9406efa 100644 --- a/_protected/app/system/core/forms/processing/CountryRestrictionCoreFormProcess.php +++ b/_protected/app/system/core/forms/processing/CountryRestrictionCoreFormProcess.php @@ -29,17 +29,18 @@ public function __construct(string $sTable) $this->sTable = $sTable; $oUserModel = new UserCoreModel; - - // First, clear everything - $oUserModel->clearCountries($this->sTable); - - // Then, reindex the table $aCountries = (array)$this->httpRequest->post('countries'); + + // Validation: Make sure at least one country has been selected if ($this->areCountriesNotSet($aCountries)) { \PFBC\Form::setError('form_country_restriction', t('You need to select at least one country.')); return; } + // Firstly, clear everything + $oUserModel->clearCountries($this->sTable); + + // Secondly, reindex the table foreach ($aCountries as $sCountry) { if ($this->isEligibleToAdd($sCountry)) { $oUserModel->addCountry($sCountry, $this->sTable);