From f5c32a3be14791d5821cad183c7a996bfcf379f7 Mon Sep 17 00:00:00 2001 From: Samuel De Backer Date: Thu, 25 Feb 2021 16:44:10 +0100 Subject: [PATCH] use of typicms.locales config --- src/TranslatableBootFormsServiceProvider.php | 6 +++++- tests/TestTranslatableBootForms.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/TranslatableBootFormsServiceProvider.php b/src/TranslatableBootFormsServiceProvider.php index 7105dbc..7480a42 100644 --- a/src/TranslatableBootFormsServiceProvider.php +++ b/src/TranslatableBootFormsServiceProvider.php @@ -28,8 +28,12 @@ public function register() // Override BootForm's form builder in order to get model binding // between BootForm & TranslatableBootForm working. $this->app->singleton('typicms.form', function ($app) { + $locales = array_keys(config('typicms.locales', [])); + if (empty($locales)) { + $locales = config('translatable-bootforms.locales'); + } $formBuilder = new FormBuilder(); - $formBuilder->setLocales(config('translatable-bootforms.locales')); + $formBuilder->setLocales($locales); $formBuilder->setErrorStore($app['typicms.form.errorstore']); $formBuilder->setOldInputProvider($app['typicms.form.oldinput']); $formBuilder->setToken($app['session.store']->token()); diff --git a/tests/TestTranslatableBootForms.php b/tests/TestTranslatableBootForms.php index a4ae0b2..7d10c6a 100644 --- a/tests/TestTranslatableBootForms.php +++ b/tests/TestTranslatableBootForms.php @@ -53,7 +53,7 @@ public function setUp(): void { parent::setUp(); - $this->app['config']->set('translatable-bootforms.locales', ['en', 'nl']); + $this->app['config']->set('typicms.locales', ['en' => 'en_US', 'nl' => 'nl_NL']); $this->app['config']->set('translatable-bootforms.label-locale-indicator', '%label (%locale)'); $this->bootform = $this->app->make('typicms.bootform');