diff --git a/lang/en/messages.php b/lang/en/messages.php
index f6339ba62df..8e92c1c6e4f 100644
--- a/lang/en/messages.php
+++ b/lang/en/messages.php
@@ -155,6 +155,7 @@
'globals_blueprint_instructions' => 'Controls the fields to be displayed when editing the variables.',
'globals_configure_handle_instructions' => 'Used to reference this global set on the frontend. This cannot be easily changed later.',
'globals_configure_intro' => 'A global set is a group of variables available across all front-end pages.',
+ 'globals_configure_layout_mode_instructions' => 'Choose how fields are arranged when editing this global set.',
'globals_configure_title_instructions' => 'Use a noun representing the set\'s contents, such as \'Brand\' or \'Company\'',
'impersonate_action_confirmation' => 'You will be logged in as this user. You can return to your account using the avatar menu.',
'licensing_config_cached_warning' => 'Any changes you make to your .env or config files will not be detected until you clear the cache. If you are seeing unexpected licensing results here, it may be because of this. You can use the php artisan config:cache command to regenerate the cache.',
diff --git a/resources/js/components/globals/PublishForm.vue b/resources/js/components/globals/PublishForm.vue
index 60bc7788000..1d8b17fb603 100644
--- a/resources/js/components/globals/PublishForm.vue
+++ b/resources/js/components/globals/PublishForm.vue
@@ -74,6 +74,7 @@
:name="publishContainer"
:reference="reference"
:blueprint="fieldset"
+ :as-config="asConfig"
v-model="values"
:meta="meta"
:origin-values="originValues"
@@ -148,6 +149,7 @@ export default {
canConfigure: Boolean,
configureUrl: String,
canEditBlueprint: Boolean,
+ asConfig: Boolean,
},
data() {
diff --git a/resources/js/pages/globals/Edit.vue b/resources/js/pages/globals/Edit.vue
index ec09a6d5e07..5f585ed358b 100644
--- a/resources/js/pages/globals/Edit.vue
+++ b/resources/js/pages/globals/Edit.vue
@@ -10,6 +10,7 @@ defineProps([
'reference',
'blueprintHandle',
'blueprint',
+ 'asConfig',
'values',
'localizedFields',
'meta',
@@ -28,7 +29,7 @@ defineProps([
-
+
args(func_get_args());
}
+ public function layoutMode($mode = null)
+ {
+ return $this->fluentlyGetOrSet('layoutMode')->args(func_get_args());
+ }
+
public function blueprint()
{
return Blueprint::find('globals.'.$this->handle());
@@ -171,6 +177,7 @@ public function fileData()
{
return Arr::removeNullValues([
'title' => $this->title(),
+ 'layout_mode' => $this->layoutMode === 'multi_column' ? 'multi_column' : null,
'sites' => Site::multiEnabled() ? $this->origins()->all() : null,
]);
}
diff --git a/src/Http/Controllers/CP/Globals/GlobalVariablesController.php b/src/Http/Controllers/CP/Globals/GlobalVariablesController.php
index 6f4d9ce7200..d8e208ab9ff 100644
--- a/src/Http/Controllers/CP/Globals/GlobalVariablesController.php
+++ b/src/Http/Controllers/CP/Globals/GlobalVariablesController.php
@@ -48,6 +48,7 @@ public function edit(Request $request, $id)
'values' => $values,
'meta' => $meta,
'blueprint' => $blueprint->toPublishArray(),
+ 'asConfig' => $set->layoutMode() === 'multi_column',
'locale' => $variables->locale(),
'localizedFields' => $variables->data()->keys()->all(),
'hasOrigin' => $hasOrigin,
diff --git a/src/Http/Controllers/CP/Globals/GlobalsController.php b/src/Http/Controllers/CP/Globals/GlobalsController.php
index 751c5bff509..b4d4496e714 100644
--- a/src/Http/Controllers/CP/Globals/GlobalsController.php
+++ b/src/Http/Controllers/CP/Globals/GlobalsController.php
@@ -67,6 +67,7 @@ public function edit($set)
$values = [
'title' => $set->title(),
'blueprint' => optional($set->blueprint())->handle(),
+ 'layout_mode' => $set->layoutMode(),
'sites' => Site::all()->map(function ($site) use ($set) {
return [
'name' => $site->name(),
@@ -100,7 +101,7 @@ public function update(Request $request, $set)
$set
->title($values['title'])
- ->blueprint($values['blueprint']);
+ ->layoutMode($values['layout_mode']);
if (Site::multiEnabled()) {
$sites = collect($values['sites'])
@@ -183,6 +184,16 @@ protected function editFormBlueprint($set)
],
],
],
+ 'layout_mode' => [
+ 'display' => __('Layout Mode'),
+ 'instructions' => __('statamic::messages.globals_configure_layout_mode_instructions'),
+ 'type' => 'button_group',
+ 'default' => 'default',
+ 'options' => [
+ 'default' => __('Default'),
+ 'multi_column' => __('Multi-column'),
+ ],
+ ],
],
],
];
diff --git a/src/Stache/Stores/GlobalsStore.php b/src/Stache/Stores/GlobalsStore.php
index a7557dd3a71..8f735758198 100644
--- a/src/Stache/Stores/GlobalsStore.php
+++ b/src/Stache/Stores/GlobalsStore.php
@@ -40,6 +40,7 @@ protected function makeBaseGlobalFromFile($handle, $path, $data)
return GlobalSet::make()
->handle($handle)
->title($data['title'] ?? null)
+ ->layoutMode($data['layout_mode'] ?? null)
->sites($data['sites'] ?? [])
->initialPath($path);
}
diff --git a/tests/Data/Globals/GlobalSetTest.php b/tests/Data/Globals/GlobalSetTest.php
index c42256af5d9..c02adb088ed 100644
--- a/tests/Data/Globals/GlobalSetTest.php
+++ b/tests/Data/Globals/GlobalSetTest.php
@@ -96,6 +96,32 @@ public function it_gets_file_contents_for_saving()
$this->assertEquals($expected, $set->fileContents());
}
+ #[Test]
+ public function it_saves_layout_mode_when_using_multi_column_layout()
+ {
+ $this->setSites([
+ 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://test.com/'],
+ 'fr' => ['name' => 'French', 'locale' => 'fr_FR', 'url' => 'http://fr.test.com/'],
+ 'de' => ['name' => 'German', 'locale' => 'de_DE', 'url' => 'http://test.com/de/'],
+ ]);
+
+ $set = (new GlobalSet)->title('The title')->sites(['en' => null, 'fr' => 'en'])->layoutMode('multi_column');
+
+ $expected = <<<'EOT'
+title: 'The title'
+layout_mode: multi_column
+sites:
+ en: null
+ fr: en
+
+EOT;
+ $this->assertEquals($expected, $set->fileContents());
+
+ $set->layoutMode('default');
+
+ $this->assertStringNotContainsString('layout_mode', $set->fileContents());
+ }
+
#[Test]
public function it_saves_through_the_api()
{
diff --git a/tests/Feature/Globals/EditGlobalVariablesTest.php b/tests/Feature/Globals/EditGlobalVariablesTest.php
index 0a52b216f65..9520c95e551 100644
--- a/tests/Feature/Globals/EditGlobalVariablesTest.php
+++ b/tests/Feature/Globals/EditGlobalVariablesTest.php
@@ -52,6 +52,7 @@ public function it_shows_the_form()
->assertSuccessful()
->assertInertia(fn (Assert $page) => $page
->component('globals/Edit')
+ ->where('asConfig', false)
->has('values', fn (Assert $page) => $page
->where('foo', 'bar')
->where('unused', null)
@@ -59,6 +60,30 @@ public function it_shows_the_form()
);
}
+ #[Test]
+ public function it_passes_as_config_when_the_global_set_uses_multi_column_layout()
+ {
+ $blueprint = Blueprint::make()->setContents(['fields' => [
+ ['handle' => 'foo', 'field' => ['type' => 'text']],
+ ]]);
+ Blueprint::partialMock();
+ Blueprint::shouldReceive('find')->with('globals.test')->andReturn($blueprint);
+ $this->setTestRoles(['test' => ['access cp', 'edit test globals']]);
+ $user = User::make()->assignRole('test')->save();
+
+ $global = GlobalSet::make('test')->layoutMode('multi_column')->save();
+ $global->in('en')->data(['foo' => 'bar'])->save();
+
+ $this
+ ->actingAs($user)
+ ->get($global->in('en')->editUrl())
+ ->assertSuccessful()
+ ->assertInertia(fn (Assert $page) => $page
+ ->component('globals/Edit')
+ ->where('asConfig', true)
+ );
+ }
+
#[Test]
public function it_shows_the_form_even_if_localization_does_not_exist()
{
diff --git a/tests/Feature/Globals/UpdateGlobalsTest.php b/tests/Feature/Globals/UpdateGlobalsTest.php
index 64f3fca6896..8158668b44b 100644
--- a/tests/Feature/Globals/UpdateGlobalsTest.php
+++ b/tests/Feature/Globals/UpdateGlobalsTest.php
@@ -42,11 +42,15 @@ public function it_updates_global_set()
$this
->actingAs($user)
- ->patchJson($global->updateUrl(), ['title' => 'Testing'])
+ ->patchJson($global->updateUrl(), [
+ 'title' => 'Testing',
+ 'layout_mode' => 'multi_column',
+ ])
->assertSuccessful();
$global = GlobalSet::find('test');
$this->assertEquals('Testing', $global->title());
+ $this->assertEquals('multi_column', $global->layoutMode());
Event::assertDispatched(GlobalSetSaved::class, function ($event) {
return $event->globals->handle() === 'test';