Skip to content

Commit 0654f5b

Browse files
authored
[5.x] Pass form_config to email view (#11417)
1 parent 38e486e commit 0654f5b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Forms/Email.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
use Illuminate\Queue\SerializesModels;
88
use Statamic\Contracts\Forms\Submission;
99
use Statamic\Facades\Antlers;
10+
use Statamic\Facades\Blueprint;
1011
use Statamic\Facades\Config;
12+
use Statamic\Facades\Form;
1113
use Statamic\Facades\GlobalSet;
1214
use Statamic\Facades\Parse;
1315
use Statamic\Sites\Site;
@@ -155,13 +157,18 @@ private function attachFiles($field)
155157
protected function addData()
156158
{
157159
$augmented = $this->submission->toAugmentedArray();
160+
$form = $this->submission->form();
158161
$fields = $this->getRenderableFieldData(Arr::except($augmented, ['id', 'date', 'form']))
159162
->reject(fn ($field) => $field['fieldtype'] === 'spacer')
160163
->when(Arr::has($this->config, 'attachments'), function ($fields) {
161164
return $fields->reject(fn ($field) => in_array($field['fieldtype'], ['assets', 'files']));
162165
});
166+
$formConfig = ($configFields = Form::extraConfigFor($form->handle()))
167+
? Blueprint::makeFromTabs($configFields)->fields()->addValues($form->data()->all())->values()->all()
168+
: [];
163169

164170
$data = array_merge($augmented, $this->getGlobalsData(), [
171+
'form_config' => $formConfig,
165172
'email_config' => $this->config,
166173
'config' => config()->all(),
167174
'fields' => $fields,

tests/Forms/EmailTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public function it_adds_data_to_the_view()
149149
'social',
150150

151151
// manual "system" vars added to email
152+
'form_config',
152153
'email_config',
153154
'config',
154155
'date',

0 commit comments

Comments
 (0)