From 3351ef17b3b70958c24f309ea04b109618070b2c Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Sun, 5 Jul 2009 07:14:03 +0000 Subject: [PATCH] MINOR: fixed validation button width. MINOR: increased title to 255 chars rather then 50 to allow for longer checkboxs --- code/UserDefinedForm.php | 32 ++++++++++++++++++++++++++++---- code/editor/EditableOption.php | 4 ++-- css/FieldEditor.css | 1 + templates/FieldEditor.ss | 2 -- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/code/UserDefinedForm.php b/code/UserDefinedForm.php index 687bf2b..20e6f0b 100755 --- a/code/UserDefinedForm.php +++ b/code/UserDefinedForm.php @@ -474,9 +474,10 @@ JS $email->setBody($recipient->EmailBody); $email->setSubject($recipient->EmailSubject); $email->setTo($recipient->EmailAddress); - // check to see if they are a dynamic recipient. eg based on a field + + // check to see if they are a dynamic sender. eg based on a email field // a user selected - if($recipient->SendEmailFromFieldID) { + if($recipient->SendEmailFromField()) { $name = Convert::raw2sql($recipient->SendEmailFromField()->Name); if(defined('Database::USE_ANSI_SQL')) { @@ -485,10 +486,26 @@ JS $submittedFormField = DataObject::get_one("SubmittedFormField", "Name = '$name' AND ParentID = '$submittedForm->ID'"); } + if($submittedFormField) { + $email->setFrom($submittedFormField->Value); + } + } + // check to see if they are a dynamic reciever eg based on a dropdown field + // a user selected + if($recipient->SendEmailToField()) { + $name = Convert::raw2sql($recipient->SendEmailToField()->Name); + + if(defined('Database::USE_ANSI_SQL')) { + $submittedFormField = DataObject::get_one("SubmittedFormField", "\"Name\" = '$name' AND \"ParentID\" = '$submittedForm->ID'"); + } else { + $submittedFormField = DataObject::get_one("SubmittedFormField", "Name = '$name' AND ParentID = '$submittedForm->ID'"); + } + if($submittedFormField) { $email->setTo($submittedFormField->Value); } } + if($recipient->SendPlain) { $body = strip_tags($recipient->EmailBody) . "\n "; if(isset($emailData['Fields'])) { @@ -549,7 +566,8 @@ class UserDefinedForm_EmailRecipient extends DataObject { static $has_one = array( 'Form' => 'UserDefinedForm', - 'SendEmailFromField' => 'EditableFormField' + 'SendEmailFromField' => 'EditableFormField', + 'SendEmailToField' => 'EditableFormField' ); /** @@ -569,7 +587,13 @@ class UserDefinedForm_EmailRecipient extends DataObject { if($validEmailFields) { $validEmailFields = $validEmailFields->toDropdownMap('ID', 'Title'); - $fields->push(new DropdownField('SendEmailFromFieldID', _t('UserDefinedForm.SENDEMAILINSTEAD', 'Send Email Instead To'),$validEmailFields, '', null, 'Use Fixed Email')); + $fields->push(new DropdownField('SendEmailFromFieldID', _t('UserDefinedForm.SENDEMAILINSTEAD', 'Send Email Instead From'),$validEmailFields, '', null, _t('UserDefinedForm.USEDEFINEDVALUE', 'Use Defined Value'))); + } + + $dropdownFields = DataObject::get("EditableMultipleOptionField", "ParentID = '$this->FormID'"); + if($dropdownFields) { + $dropdownFields = $dropdownFields->toDropdownMap('ID', 'Title'); + $fields->push(new DropdownField('SendEmailToFieldID', _t('UserDefinedForm.SENDEMAILTO', 'Send Email Instead To'), $dropdownFields, '', null, _t('UserDefinedForm.USEDEFINEDVALUE', 'Use Defined Value'))); } } $fields->push(new TextareaField('EmailBody', 'Body')); diff --git a/code/editor/EditableOption.php b/code/editor/EditableOption.php index ef383c7..bdb923a 100644 --- a/code/editor/EditableOption.php +++ b/code/editor/EditableOption.php @@ -12,8 +12,8 @@ class EditableOption extends DataObject { static $default_sort = "Sort"; static $db = array( - "Name" => "Varchar", - "Title" => "Varchar", + "Name" => "Varchar(255)", + "Title" => "Varchar(255)", "Default" => "Boolean", "Sort" => "Int" ); diff --git a/css/FieldEditor.css b/css/FieldEditor.css index b87be96..4ecdcda 100755 --- a/css/FieldEditor.css +++ b/css/FieldEditor.css @@ -161,6 +161,7 @@ #Fields_fields .EditableFormField .checkbox input { float: left; + width:auto; margin: 0 8px 0 0; } diff --git a/templates/FieldEditor.ss b/templates/FieldEditor.ss index 12ec1c2..b3a6b68 100755 --- a/templates/FieldEditor.ss +++ b/templates/FieldEditor.ss @@ -1,6 +1,4 @@
- - <% include AddField %>