set(SSViewer::class, 'theme_enabled', true); Requirements::clear(); $content = $this->customise([ 'Body' => $this->record->getEmailBodyContent(), 'HideFormData' => (bool) $this->record->HideFormData, 'Fields' => $this->getPreviewFieldData() ])->renderWith($this->record->EmailTemplate); Requirements::restore(); Config::unnest(); return $content; } /** * Get some placeholder field values to display in the preview * * @return ArrayList */ protected function getPreviewFieldData() { $data = ArrayList::create(); $fields = $this->record->Form()->Fields(); foreach ($fields as $field) { if (!$field->showInReports()) { continue; } $data->push(ArrayData::create([ 'Name' => $field->dbObject('Name'), 'Title' => $field->dbObject('Title'), 'Value' => DBField::create_field('Varchar', '$' . $field->Name), 'FormattedValue' => DBField::create_field('Varchar', '$' . $field->Name) ])); } return $data; } }