diff --git a/app/sprinkles/account/src/Controller/AccountController.php b/app/sprinkles/account/src/Controller/AccountController.php index 46d890896..fab4c09de 100644 --- a/app/sprinkles/account/src/Controller/AccountController.php +++ b/app/sprinkles/account/src/Controller/AccountController.php @@ -509,12 +509,22 @@ public function pageRegister(Request $request, Response $response, $args) // Get locale information $currentLocales = $localePathBuilder->getLocales(); + // Hide the locale field if there is only 1 locale available + $fields = [ + 'hidden' => [], + 'disabled' => [] + ]; + if (count($config->getDefined('site.locales.available')) <= 1) { + $fields['hidden'][] = 'locale'; + } + return $this->ci->view->render($response, 'pages/register.html.twig', [ 'page' => [ 'validators' => [ 'register' => $validatorRegister->rules('json', false) ] ], + 'fields' => $fields, 'locales' => [ 'available' => $config['site.locales.available'], 'current' => end($currentLocales) @@ -658,8 +668,18 @@ public function pageSettings(Request $request, Response $response, $args) // Get a list of all locales $locales = $config->getDefined('site.locales.available'); + // Hide the locale field if there is only 1 locale available + $fields = [ + 'hidden' => [], + 'disabled' => [] + ]; + if (count($config->getDefined('site.locales.available')) <= 1) { + $fields['hidden'][] = 'locale'; + } + return $this->ci->view->render($response, 'pages/account-settings.html.twig', [ 'locales' => $locales, + 'fields' => $fields, 'page' => [ 'validators' => [ 'account_settings' => $validatorAccountSettings->rules('json', false), @@ -766,6 +786,11 @@ public function profile(Request $request, Response $response, $args) $error = false; + // Ensure that in the case of using a single locale, that the locale is set + if (count($config->getDefined('site.locales.available')) <= 1) { + $data['locale'] = $currentUser->locale; + } + // Validate, and halt on validation errors. $validator = new ServerSideValidator($schema, $this->ci->translator); if (!$validator->validate($data)) { @@ -877,6 +902,11 @@ public function register(Request $request, Response $response, $args) $error = false; + // Ensure that in the case of using a single locale, that the locale is set + if (count($config->getDefined('site.locales.available')) <= 1) { + $data['locale'] = $config['site.registration.user_defaults.locale']; + } + // Validate request data $validator = new ServerSideValidator($schema, $this->ci->translator); if (!$validator->validate($data)) { @@ -1163,6 +1193,11 @@ public function settings(Request $request, Response $response, $args) $error = false; + // Ensure that in the case of using a single locale, that the locale is set + if (count($config->getDefined('site.locales.available')) <= 1) { + $data['locale'] = $currentUser->locale; + } + // Validate, and halt on validation errors. $validator = new ServerSideValidator($schema, $this->ci->translator); if (!$validator->validate($data)) { diff --git a/app/sprinkles/account/templates/forms/settings-profile.html.twig b/app/sprinkles/account/templates/forms/settings-profile.html.twig index 0b0a788ab..109bc5576 100644 --- a/app/sprinkles/account/templates/forms/settings-profile.html.twig +++ b/app/sprinkles/account/templates/forms/settings-profile.html.twig @@ -20,6 +20,7 @@ + {% if 'locale' not in fields.hidden %}
{{translate("LOCALE.ACCOUNT")}}.
{{translate("LOCALE.ACCOUNT")}}.