From eba5edd60b6e74a73982469ae556fb5a7523ddca Mon Sep 17 00:00:00 2001 From: Kirk Mayo Date: Tue, 17 Jul 2012 15:58:24 +1200 Subject: [PATCH] BUG: open ticket 7314 fixing some bugs that have been found --- code/model/UserDefinedForm.php | 30 ++++++++++--------- .../model/formfields/EditableLiteralField.php | 8 +++-- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/code/model/UserDefinedForm.php b/code/model/UserDefinedForm.php index e82cf81..5e032b6 100755 --- a/code/model/UserDefinedForm.php +++ b/code/model/UserDefinedForm.php @@ -70,11 +70,11 @@ class UserDefinedForm extends Page { $fields->addFieldToTab("Root.Submissions", new CheckboxField('DisableSaveSubmissions',_t('UserDefinedForm.SAVESUBMISSIONS',"Disable Saving Submissions to Server"))); $fields->addFieldToTab("Root.Submissions", new SubmittedFormReportField( "Reports", _t('UserDefinedForm.RECEIVED', 'Received Submissions'), "", $this ) ); - UserDefinedForm_EmailRecipient::$summary_fields=array( - 'EmailAddress' => _t('UserDefinedForm.EMAILADDRESS', 'Email'), - 'EmailSubject' => _t('UserDefinedForm.EMAILSUBJECT', 'Subject'), - 'EmailFrom' => _t('UserDefinedForm.EMAILFROM', 'From') - ); + UserDefinedForm_EmailRecipient::$summary_fields=array( + 'EmailAddress' => _t('UserDefinedForm.EMAILADDRESS', 'Email'), + 'EmailSubject' => _t('UserDefinedForm.EMAILSUBJECT', 'Subject'), + 'EmailFrom' => _t('UserDefinedForm.EMAILFROM', 'From') + ); // who do we email on submission $emailRecipients = new GridField("EmailRecipients", "EmailRecipients", $this->EmailRecipients(), GridFieldConfig_RecordEditor::create(10)); @@ -85,7 +85,7 @@ class UserDefinedForm extends Page { $onCompleteFieldSet = new FieldList( $editor=new HtmlEditorField( "OnCompleteMessage", _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion'), _t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage)) ); - $editor->setRows(3); + $editor->setRows(3); $fields->addFieldsToTab("Root.OnComplete", $onCompleteFieldSet); $fields->addFieldsToTab("Root.Options", $this->getFormOptions()); @@ -672,7 +672,7 @@ JS if(!$this->DisableSaveSubmissions) $submittedForm->write(); $values = array(); - $attachments = array(); + $attachments = array(); $submittedFields = new ArrayList(); @@ -756,7 +756,7 @@ JS // check to see if they are a dynamic sender. eg based on a email field a user selected if($recipient->SendEmailFromField()) { $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailFromField()->Name); - if($submittedFormField) { + if($submittedFormField && is_string($submittedFormField->Value)) { $email->setFrom($submittedFormField->Value); } } @@ -764,12 +764,12 @@ JS if($recipient->SendEmailToField()) { $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailToField()->Name); - if($submittedFormField) { + if($submittedFormField && is_string($submittedFormField->Value)) { $email->setTo($submittedFormField->Value); } } - $this->extend('updateEmail', $email, $recipient, $emailData); + $this->extend('updateEmail', $email, $recipient, $emailData); if($recipient->SendPlain) { $body = strip_tags($recipient->EmailBody) . "\n "; @@ -859,7 +859,8 @@ class UserDefinedForm_EmailRecipient extends DataObject { // if they have email fields then we could send from it if($validEmailFields) { - $fields->insertAfter(new DropdownField('SendEmailFromFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASFROM', '.. or Select a Form Field to use as the From Address'), $validEmailFields->map('ID', 'Title'), '', null,""), 'EmailFrom'); + $fields->insertAfter(new DropdownField('SendEmailFromFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASFROM', '.. or Select a Form Field to use as the From Address'), + $validEmailFields->map('ID', 'Title'), '', null,""), 'EmailFrom'); } // if they have multiple options @@ -875,7 +876,8 @@ class UserDefinedForm_EmailRecipient extends DataObject { } $multiOptionFields = $multiOptionFields->map('ID', 'Title'); - $fields->insertAfter(new DropdownField('SendEmailToFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASTO', '.. or Select a Field to use as the To Address'), $multiOptionFields, '', null, ""), 'EmailAddress'); + $fields->insertAfter(new DropdownField('SendEmailToFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASTO', '.. or Select a Field to use as the To Address'), + $multiOptionFields, '', null, ""), 'EmailAddress'); } } @@ -904,7 +906,7 @@ class UserDefinedForm_SubmittedFormEmail extends Email { protected $ss_template = "SubmittedFormEmail"; protected $data; - public function __construct() { - parent::__construct(); + public function __construct($submittedFields = null) { + parent::__construct($submittedFields = null); } } diff --git a/code/model/formfields/EditableLiteralField.php b/code/model/formfields/EditableLiteralField.php index e56f737..a7942d4 100644 --- a/code/model/formfields/EditableLiteralField.php +++ b/code/model/formfields/EditableLiteralField.php @@ -14,10 +14,12 @@ class EditableLiteralField extends EditableFormField { static $plural_name = 'HTML Blocks'; public function getFieldConfiguration() { - + $customSettings = unserialize($this->CustomSettings); + $content = (isset($customSettings['Content'])) ? $customSettings['Content'] : ''; $textAreaField = new TextareaField( $this->getSettingName('Content'), - "HTML" + "HTML", + $content ); $textAreaField->setRows(4); $textAreaField->setColumns(20); @@ -44,4 +46,4 @@ class EditableLiteralField extends EditableFormField { public function showInReports() { return (!$this->getSetting('HideFromReports')); } -} \ No newline at end of file +}