mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Test
This commit is contained in:
parent
c4fe6beca5
commit
ae1136c565
@ -977,8 +977,8 @@ JS
|
|||||||
$email->populateTemplate($emailData);
|
$email->populateTemplate($emailData);
|
||||||
$email->setFrom($recipient->EmailFrom);
|
$email->setFrom($recipient->EmailFrom);
|
||||||
$email->setBody($recipient->EmailBody);
|
$email->setBody($recipient->EmailBody);
|
||||||
$email->setSubject($recipient->EmailSubject);
|
|
||||||
$email->setTo($recipient->EmailAddress);
|
$email->setTo($recipient->EmailAddress);
|
||||||
|
$email->setSubject($recipient->EmailSubject)
|
||||||
|
|
||||||
if($recipient->EmailReplyTo) {
|
if($recipient->EmailReplyTo) {
|
||||||
$email->setReplyTo($recipient->EmailReplyTo);
|
$email->setReplyTo($recipient->EmailReplyTo);
|
||||||
@ -1001,6 +1001,12 @@ JS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check to see if there is a dynamic subject
|
||||||
|
if($recipient->SendEmailSubjectField()) {
|
||||||
|
$submittedFormField = $submittedFields->find('Name', $recipient->SendEmailSubjectField()->Name);
|
||||||
|
$email->setSubject($submittedFormField->Value);
|
||||||
|
}
|
||||||
|
|
||||||
$this->extend('updateEmail', $email, $recipient, $emailData);
|
$this->extend('updateEmail', $email, $recipient, $emailData);
|
||||||
|
|
||||||
if($recipient->SendPlain) {
|
if($recipient->SendPlain) {
|
||||||
@ -1100,7 +1106,8 @@ class UserDefinedForm_EmailRecipient extends DataObject {
|
|||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Form' => 'UserDefinedForm',
|
'Form' => 'UserDefinedForm',
|
||||||
'SendEmailFromField' => 'EditableFormField',
|
'SendEmailFromField' => 'EditableFormField',
|
||||||
'SendEmailToField' => 'EditableFormField'
|
'SendEmailToField' => 'EditableFormField',
|
||||||
|
'SendEmailSubjectField' => 'EditableFormField'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $summary_fields = array();
|
private static $summary_fields = array();
|
||||||
@ -1129,41 +1136,34 @@ class UserDefinedForm_EmailRecipient extends DataObject {
|
|||||||
|
|
||||||
if($this->Form()) {
|
if($this->Form()) {
|
||||||
$dropdowns = array();
|
$dropdowns = array();
|
||||||
|
|
||||||
$validEmailFields = DataObject::get("EditableEmailField", "\"ParentID\" = '" . (int)$this->FormID . "'");
|
$validEmailFields = DataObject::get("EditableEmailField", "\"ParentID\" = '" . (int)$this->FormID . "'");
|
||||||
$multiOptionFields = DataObject::get("EditableMultipleOptionField", "\"ParentID\" = '" . (int)$this->FormID . "'");
|
$multiOptionFields = DataObject::get("EditableMultipleOptionField", "\"ParentID\" = '" . (int)$this->FormID . "'");
|
||||||
|
$validSubjectFields = EditableTextField::get()->filter('ParentID', $this->FormID)->filterByCallback(function($item, $list) { return $item->getSetting('Rows') === 1; });
|
||||||
|
|
||||||
// if they have email fields then we could send from it
|
$fields->insertAfter($dropdowns[] = new DropdownField(
|
||||||
|
'SendEmailFromFieldID',
|
||||||
|
_t('UserDefinedForm.ORSELECTAFIELDTOUSEASFROM', '.. or select a field to use as reply to address'),
|
||||||
|
$validEmailFields->map('ID', 'Title')
|
||||||
|
), 'EmailReplyTo');
|
||||||
|
|
||||||
|
if($multiOptionFields) {
|
||||||
|
$validEmailFields = $validEmailFields->toArrayList();
|
||||||
|
$validEmailFields->merge($multiOptionFields);
|
||||||
|
$validSubjectFields->merge($multiOptionFields);
|
||||||
|
}
|
||||||
if($validEmailFields) {
|
if($validEmailFields) {
|
||||||
$fields->insertAfter($dropdowns[] = new DropdownField(
|
$fields->insertAfter($dropdowns[] = new DropdownField(
|
||||||
'SendEmailFromFieldID',
|
'SendEmailToFieldID',
|
||||||
_t('UserDefinedForm.ORSELECTAFIELDTOUSEASFROM', '.. or select a field to use as reply to address'),
|
_t('UserDefinedForm.ORSELECTAFIELDTOUSEASTO', '.. or select a field to use as the to address'),
|
||||||
$validEmailFields->map('ID', 'Title')
|
$validEmailFields = $validEmailFields->map('ID', 'Title');
|
||||||
), 'EmailReplyTo');
|
|
||||||
}
|
|
||||||
|
|
||||||
// if they have multiple options
|
|
||||||
if($multiOptionFields || $validEmailFields) {
|
|
||||||
|
|
||||||
if($multiOptionFields && $validEmailFields) {
|
|
||||||
$multiOptionFields = $multiOptionFields->toArray();
|
|
||||||
$multiOptionFields = array_merge(
|
|
||||||
$multiOptionFields,
|
|
||||||
$validEmailFields->toArray()
|
|
||||||
);
|
|
||||||
|
|
||||||
$multiOptionFields = ArrayList::create($multiOptionFields);
|
|
||||||
}
|
|
||||||
else if(!$multiOptionFields) {
|
|
||||||
$multiOptionFields = $validEmailFields;
|
|
||||||
}
|
|
||||||
|
|
||||||
$multiOptionFields = $multiOptionFields->map('ID', 'Title');
|
|
||||||
$fields->insertAfter($dropdowns[] = new DropdownField(
|
|
||||||
'SendEmailToFieldID',
|
|
||||||
_t('UserDefinedForm.ORSELECTAFIELDTOUSEASTO', '.. or select a field to use as the to address'),
|
|
||||||
$multiOptionFields
|
|
||||||
), 'EmailAddress');
|
), 'EmailAddress');
|
||||||
|
}
|
||||||
|
if($validSubjectFields) {
|
||||||
|
$fields->insertAfter($dropdowns[] = new DropdownField(
|
||||||
|
'SendEmailSubjectFieldID',
|
||||||
|
_t('UserDefinedForm.SELECTAFIELDTOSETSUBJECT', '... or select a field to use as the subject'),
|
||||||
|
$validSubjectFields->map('ID', 'Title')
|
||||||
|
), 'SendEmailSubjectField');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($dropdowns) {
|
if($dropdowns) {
|
||||||
|
Loading…
Reference in New Issue
Block a user