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
|
||||
*/
|
||||
function process($data, $form) {
|
||||
|
||||
// submitted form object
|
||||
$submittedForm = new SubmittedForm();
|
||||
$submittedForm->SubmittedBy = Member::currentUser();
|
||||
@ -380,40 +379,38 @@ JS
|
||||
$submittedFields->push($submittedField);
|
||||
|
||||
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){
|
||||
case "EditableFileField" :
|
||||
if(isset($_FILES[$field->Name])) {
|
||||
|
||||
// create the file from post data
|
||||
$upload = new Upload();
|
||||
$file = new File();
|
||||
$upload->loadIntoFile($_FILES[$field->Name], $file);
|
||||
// write file to form field
|
||||
$submittedField->UploadedFileID = $file->ID;
|
||||
|
||||
// Attach the file if its less than 1MB, provide a link if its over.
|
||||
if($file->getAbsoluteSize() < 1024*1024*1){
|
||||
$attachments[] = $file;
|
||||
}
|
||||
|
||||
// write file to form field
|
||||
$submittedField->UploadedFileID = $file->ID;
|
||||
|
||||
// Attach the file if its less than 1MB, provide a link if its over.
|
||||
if($file->getAbsoluteSize() < 1024*1024*1){
|
||||
$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;
|
||||
// Always provide the link if present.
|
||||
if($file->ID) {
|
||||
$submittedField->Value = "<a href=\"". $file->getFilename() ."\" title=\"". $file->getFilename() . "\">". $file->Title . "</a>";
|
||||
} else {
|
||||
$submittedField->Value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($field->hasMethod('getValueFromData')) {
|
||||
$values[$field->Title] = Convert::linkIfMatch($field->getValueFromData($data));
|
||||
} else {
|
||||
if(isset($data[$field->Name])) $values[$field->Title] = Convert::linkIfMatch($data[$field->Name]);
|
||||
}
|
||||
|
||||
// make sure we save
|
||||
$submittedField->write();
|
||||
}
|
||||
$emailData = array(
|
||||
"Sender" => Member::currentUser(),
|
||||
|
@ -23,12 +23,12 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField {
|
||||
|
||||
function getValueFromData($data) {
|
||||
$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(!is_array($data[$this->Name])) {
|
||||
$entries = array($data[$this->Name]);
|
||||
}
|
||||
foreach($entries as $selected => $value) {
|
||||
if(!$result) {
|
||||
$result = $value;
|
||||
|
@ -30,5 +30,6 @@ class EditableFileField extends EditableFormField {
|
||||
public function getFormField() {
|
||||
return new FileField($this->Name, $this->Title);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user