mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
MINOR: fixed notices and tidied up code
This commit is contained in:
parent
ecdb0e009a
commit
f19924d92f
@ -347,7 +347,6 @@ JS
|
|||||||
* @return Redirection
|
* @return Redirection
|
||||||
*/
|
*/
|
||||||
function process($data, $form) {
|
function process($data, $form) {
|
||||||
|
|
||||||
// submitted form object
|
// submitted form object
|
||||||
$submittedForm = new SubmittedForm();
|
$submittedForm = new SubmittedForm();
|
||||||
$submittedForm->SubmittedBy = Member::currentUser();
|
$submittedForm->SubmittedBy = Member::currentUser();
|
||||||
@ -380,40 +379,38 @@ JS
|
|||||||
$submittedFields->push($submittedField);
|
$submittedFields->push($submittedField);
|
||||||
|
|
||||||
if(!empty($data[$field->Name])){
|
if(!empty($data[$field->Name])){
|
||||||
|
/**
|
||||||
|
* @todo this should be on the EditableFile class. Just need to sort out
|
||||||
|
* attachments array
|
||||||
|
*/
|
||||||
|
if($field->ClassName == "EditableFileField"){
|
||||||
|
if(isset($_FILES[$field->Name])) {
|
||||||
|
|
||||||
|
// create the file from post data
|
||||||
|
$upload = new Upload();
|
||||||
|
$file = new File();
|
||||||
|
$upload->loadIntoFile($_FILES[$field->Name], $file);
|
||||||
|
|
||||||
switch($field->ClassName){
|
// write file to form field
|
||||||
case "EditableFileField" :
|
$submittedField->UploadedFileID = $file->ID;
|
||||||
if(isset($_FILES[$field->Name])) {
|
|
||||||
|
// Attach the file if its less than 1MB, provide a link if its over.
|
||||||
// create the file from post data
|
if($file->getAbsoluteSize() < 1024*1024*1){
|
||||||
$upload = new Upload();
|
$attachments[] = $file;
|
||||||
$file = new File();
|
}
|
||||||
$upload->loadIntoFile($_FILES[$field->Name], $file);
|
|
||||||
|
|
||||||
// write file to form field
|
// Always provide the link if present.
|
||||||
$submittedField->UploadedFileID = $file->ID;
|
if($file->ID) {
|
||||||
|
$submittedField->Value = "<a href=\"". $file->getFilename() ."\" title=\"". $file->getFilename() . "\">". $file->Title . "</a>";
|
||||||
// Attach the file if its less than 1MB, provide a link if its over.
|
} else {
|
||||||
if($file->getAbsoluteSize() < 1024*1024*1){
|
$submittedField->Value = "";
|
||||||
$attachments[] = $file;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always provide the link if present.
|
|
||||||
if($file->ID) {
|
|
||||||
$submittedField->Value = "<a href=\"". $file->getFilename() ."\" title=\"". $file->getFilename() . "\">". $file->Title . "</a>";
|
|
||||||
} else {
|
|
||||||
$submittedField->Value = "";
|
|
||||||
}
|
|
||||||
$submittedField->write();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif($field->hasMethod('getValueFromData')) {
|
|
||||||
$values[$field->Title] = Convert::linkIfMatch($field->getValueFromData($data));
|
// make sure we save
|
||||||
} else {
|
$submittedField->write();
|
||||||
if(isset($data[$field->Name])) $values[$field->Title] = Convert::linkIfMatch($data[$field->Name]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$emailData = array(
|
$emailData = array(
|
||||||
"Sender" => Member::currentUser(),
|
"Sender" => Member::currentUser(),
|
||||||
|
@ -23,12 +23,12 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField {
|
|||||||
|
|
||||||
function getValueFromData($data) {
|
function getValueFromData($data) {
|
||||||
$result = '';
|
$result = '';
|
||||||
$entries = $data[$this->Name];
|
$entries = (isset($data[$this->Name])) ? $data[$this->Name] : false;
|
||||||
|
|
||||||
if(!is_array($data[$this->Name])) {
|
|
||||||
$entries = array($data[$this->Name]);
|
|
||||||
}
|
|
||||||
if($entries) {
|
if($entries) {
|
||||||
|
if(!is_array($data[$this->Name])) {
|
||||||
|
$entries = array($data[$this->Name]);
|
||||||
|
}
|
||||||
foreach($entries as $selected => $value) {
|
foreach($entries as $selected => $value) {
|
||||||
if(!$result) {
|
if(!$result) {
|
||||||
$result = $value;
|
$result = $value;
|
||||||
|
@ -30,5 +30,6 @@ class EditableFileField extends EditableFormField {
|
|||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
return new FileField($this->Name, $this->Title);
|
return new FileField($this->Name, $this->Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user