mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Merge pull request #283 from open-sausages/feature/test-recipient-email
Display form fields correctly in email preview
This commit is contained in:
commit
08b2e573f4
@ -1596,9 +1596,35 @@ class UserDefinedForm_EmailRecipient_ItemRequest extends GridFieldDetailForm_Ite
|
||||
*/
|
||||
public function preview() {
|
||||
return $this->customise(new ArrayData(array(
|
||||
'Body' => $this->record->getEmailBodyContent()
|
||||
'Body' => $this->record->getEmailBodyContent(),
|
||||
'HideFormData' => $this->record->HideFormData,
|
||||
'Fields' => $this->getPreviewFieldData()
|
||||
)))->renderWith($this->record->EmailTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get some placeholder field values to display in the preview
|
||||
* @return ArrayList
|
||||
*/
|
||||
private function getPreviewFieldData() {
|
||||
$data = new ArrayList();
|
||||
|
||||
$fields = $this->record->Form()->Fields()->filter(array(
|
||||
'ClassName:not' => 'EditableLiteralField',
|
||||
'ClassName:not' => 'EditableFormHeading'
|
||||
));
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$data->push(new ArrayData(array(
|
||||
'Name' => $field->Name,
|
||||
'Title' => $field->Title,
|
||||
'Value' => '$' . $field->Name,
|
||||
'FormattedValue' => '$' . $field->Name
|
||||
)));
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user