From 8fd028265b2ac7f6a2fc2e701e05125bc701059d Mon Sep 17 00:00:00 2001 From: Laurens Kuiper Date: Wed, 23 Sep 2026 14:06:13 +0200 Subject: [PATCH] Augment appended form config fields in emails --- src/Forms/Email.php | 2 +- tests/Forms/EmailTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Forms/Email.php b/src/Forms/Email.php index 41adbc0566e..06b9faef831 100644 --- a/src/Forms/Email.php +++ b/src/Forms/Email.php @@ -168,7 +168,7 @@ protected function addData() return $fields->reject(fn ($field) => in_array($field['fieldtype'], ['assets', 'files'])); }); $formConfig = ($configFields = Form::extraConfigFor($form->handle())) - ? Blueprint::makeFromTabs($configFields)->fields()->addValues($form->data()->all())->values()->all() + ? Blueprint::makeFromTabs($configFields)->fields()->addValues($form->data()->all())->augment()->values()->all() : []; $data = array_merge($augmented, $this->getGlobalsData(), [ diff --git a/tests/Forms/EmailTest.php b/tests/Forms/EmailTest.php index 1efd59edf46..4f008929cd3 100644 --- a/tests/Forms/EmailTest.php +++ b/tests/Forms/EmailTest.php @@ -168,6 +168,30 @@ public function it_adds_data_to_the_view() $this->assertEquals('Statamic', (string) $email->viewData['company']['company_name']); } + #[Test] + public function it_augments_appended_config_fields() + { + $formBlueprint = Blueprint::makeFromFields(['foo' => ['type' => 'text']]); + BlueprintRepository::shouldReceive('find')->with('forms.test')->andReturn($formBlueprint); + BlueprintRepository::shouldReceive('makeFromTabs')->passthru(); + BlueprintRepository::shouldReceive('make')->passthru(); + + Form::appendConfigFields('*', 'Fields', [ + 'test_config' => ['type' => 'bard', 'display' => 'A Bard field'], + ]); + + $form = tap(Form::make('test')->data([ + 'test_config' => [['type' => 'paragraph', 'content' => [['type' => 'text', 'text' => 'Shut up, Malacoustix!']]]], + ]))->save(); + + $email = $this->makeEmailWithSubmission($form->makeSubmission()->data(['foo' => 'bar'])); + + $this->assertStringContainsString( + '

Shut up, Malacoustix!

', + (string) $email->viewData['form_config']['test_config'] + ); + } + #[Test] public function it_escapes_submitted_values_in_the_automagic_email() {