Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for including all form data in email body #97

Merged
merged 3 commits into from
Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/controllers/SendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ public function actionIndex()
$submission->fromEmail = $request->getBodyParam('fromEmail');
$submission->fromName = $request->getBodyParam('fromName');
$submission->subject = $request->getBodyParam('subject');
$submission->message = $request->getBodyParam('message');

if ($settings->includeAllData) {
$submission->message = "<p>Name: {$request->getBodyParam('fromName')}</p>".
Copy link
Member

@brandonkelly brandonkelly Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message should be set to Markdown-formatted text, not HTML. Each of these <p>s should be regular lines of text, separated by two \ns. Or perhaps a bullet list would work better here (begin each line with a - and separate them with single \ns).

"<p>Email: {$request->getBodyParam('fromEmail')}</p>".
"<p>Subject: {$request->getBodyParam('subject')}</p>".
"<p>{$request->getBodyParam('message')}</p>";
} else {
$submission->message = $request->getBodyParam('message');
}

if ($settings->allowAttachments && isset($_FILES['attachment']) && isset($_FILES['attachment']['name'])) {
if (is_array($_FILES['attachment']['name'])) {
Expand Down
5 changes: 5 additions & 0 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class Settings extends Model
*/
public $allowAttachments = false;

/**
* @var bool
*/
public $includeAllData = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure a setting is necessary for this. I'm sure most people would be fine to have the additional info in the body.


/**
* @var string|null
*/
Expand Down
10 changes: 10 additions & 0 deletions src/templates/_settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@
errors: settings.getErrors('allowAttachments')
}) }}

{{ forms.lightswitchField({
label: "Include all data in email body?"|t('contact-form'),
id: 'includeAllData',
name: 'includeAllData',
on: settings.includeAllData,
disabled: 'includeAllData' in overrides,
warning: 'includeAllData' in overrides ? configWarning('includeAllData'),
errors: settings.getErrors('includeAllData')
}) }}

{{ forms.textField({
label: "Success Flash Message"|t('contact-form'),
id: "successFlashMessage",
Expand Down
2 changes: 2 additions & 0 deletions src/translations/de/contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
=> "Text, welcher der Betreffzeile vorangestellt wird, um aufzuzeigen dass die Mail vom Kontaktformular stammt",
"Allow attachments?"
=> "Anlagen erlauben?",
"Include all data in email body?"
=> "Alle Daten in Mail einbeziehen?",
"Success Flash Message"
=> "Erfolgsnachricht",
"The flash message diplayed after successfully sending a message."
Expand Down