mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
BUG Fix file field ignoring allowed extensions
This commit is contained in:
parent
31822a5c08
commit
1df5b93dce
@ -32,6 +32,11 @@ class EditableFileField extends EditableFormField {
|
|||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
$field = FileField::create($this->Name, $this->Title);
|
$field = FileField::create($this->Name, $this->Title);
|
||||||
|
|
||||||
|
// filter out '' since this would be a regex problem on JS end
|
||||||
|
$field->getValidator()->setAllowedExtensions(
|
||||||
|
array_filter(Config::inst()->get('File', 'allowed_extensions'))
|
||||||
|
);
|
||||||
|
|
||||||
if($this->getSetting('Folder')) {
|
if($this->getSetting('Folder')) {
|
||||||
$folder = Folder::get()->byId($this->getSetting('Folder'));
|
$folder = Folder::get()->byId($this->getSetting('Folder'));
|
||||||
|
|
||||||
|
@ -327,6 +327,14 @@ class EditableFormFieldTest extends FunctionalTest {
|
|||||||
$this->assertNotNull($validationField);
|
$this->assertNotNull($validationField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFileField() {
|
||||||
|
$fileField = $this->objFromFixture('EditableFileField', 'file-field');
|
||||||
|
$formField = $fileField->getFormField();
|
||||||
|
|
||||||
|
$this->assertContains('jpg', $formField->getValidator()->getAllowedExtensions());
|
||||||
|
$this->assertNotContains('notallowedextension', $formField->getValidator()->getAllowedExtensions());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,135 +1,141 @@
|
|||||||
EditableOption:
|
EditableOption:
|
||||||
option-1:
|
option-1:
|
||||||
Name: Option1
|
Name: Option1
|
||||||
Title: Option 1
|
Title: Option 1
|
||||||
|
|
||||||
|
option-2:
|
||||||
|
Name: Option2
|
||||||
|
Title: Option 2
|
||||||
|
|
||||||
|
department-1:
|
||||||
|
Name: dept1
|
||||||
|
Title: sales@example.com
|
||||||
|
|
||||||
|
department-2:
|
||||||
|
Name: dept2
|
||||||
|
Title: accounts@example.com
|
||||||
|
|
||||||
|
option-3:
|
||||||
|
Name: Option3
|
||||||
|
Title: Option 3
|
||||||
|
|
||||||
|
option-4:
|
||||||
|
Name: Option4
|
||||||
|
Title: Option 4
|
||||||
|
|
||||||
|
option-5:
|
||||||
|
Name: Option5
|
||||||
|
Title: Option 5
|
||||||
|
|
||||||
|
option-6:
|
||||||
|
Name: Option6
|
||||||
|
Title: Option 6
|
||||||
|
|
||||||
option-2:
|
|
||||||
Name: Option2
|
|
||||||
Title: Option 2
|
|
||||||
|
|
||||||
department-1:
|
|
||||||
Name: dept1
|
|
||||||
Title: sales@example.com
|
|
||||||
|
|
||||||
department-2:
|
|
||||||
Name: dept2
|
|
||||||
Title: accounts@example.com
|
|
||||||
|
|
||||||
option-3:
|
|
||||||
Name: Option3
|
|
||||||
Title: Option 3
|
|
||||||
|
|
||||||
option-4:
|
|
||||||
Name: Option4
|
|
||||||
Title: Option 4
|
|
||||||
|
|
||||||
option-5:
|
|
||||||
Name: Option5
|
|
||||||
Title: Option 5
|
|
||||||
|
|
||||||
option-6:
|
|
||||||
Name: Option6
|
|
||||||
Title: Option 6
|
|
||||||
|
|
||||||
UserDefinedForm_EmailRecipient:
|
UserDefinedForm_EmailRecipient:
|
||||||
recipient-1:
|
recipient-1:
|
||||||
EmailAddress: test@example.com
|
EmailAddress: test@example.com
|
||||||
EmailSubject: Email Subject
|
EmailSubject: Email Subject
|
||||||
EmailFrom: no-reply@example.com
|
EmailFrom: no-reply@example.com
|
||||||
|
|
||||||
no-html:
|
|
||||||
EmailAddress: nohtml@example.com
|
|
||||||
EmailSubject: Email Subject
|
|
||||||
EmailFrom: no-reply@example.com
|
|
||||||
SendPlain: true
|
|
||||||
|
|
||||||
no-data:
|
|
||||||
EmailAddress: nodata@example.com
|
|
||||||
EmailSubject: Email Subject
|
|
||||||
EmailFrom: no-reply@example.com
|
|
||||||
HideFormData: true
|
|
||||||
|
|
||||||
|
no-html:
|
||||||
|
EmailAddress: nohtml@example.com
|
||||||
|
EmailSubject: Email Subject
|
||||||
|
EmailFrom: no-reply@example.com
|
||||||
|
SendPlain: true
|
||||||
|
|
||||||
|
no-data:
|
||||||
|
EmailAddress: nodata@example.com
|
||||||
|
EmailSubject: Email Subject
|
||||||
|
EmailFrom: no-reply@example.com
|
||||||
|
HideFormData: true
|
||||||
|
|
||||||
EditableTextField:
|
EditableTextField:
|
||||||
basic-text:
|
basic-text:
|
||||||
Name: basic-text-name
|
Name: basic-text-name
|
||||||
Title: Basic Text Field
|
Title: Basic Text Field
|
||||||
|
|
||||||
basic-text-2:
|
basic-text-2:
|
||||||
Name: basic-text-name
|
Name: basic-text-name
|
||||||
Title: Basic Text Field
|
Title: Basic Text Field
|
||||||
|
|
||||||
required-text:
|
required-text:
|
||||||
Name: required-text-field
|
Name: required-text-field
|
||||||
Title: Required Text Field
|
Title: Required Text Field
|
||||||
CustomErrorMessage: Custom Error Message
|
CustomErrorMessage: Custom Error Message
|
||||||
Required: true
|
Required: true
|
||||||
|
|
||||||
EditableDropdown:
|
EditableDropdown:
|
||||||
basic-dropdown:
|
basic-dropdown:
|
||||||
Name: basic-dropdown
|
Name: basic-dropdown
|
||||||
Title: Basic Dropdown Field
|
Title: Basic Dropdown Field
|
||||||
Options: =>EditableOption.option-1, =>EditableOption.option-2
|
Options: =>EditableOption.option-1, =>EditableOption.option-2
|
||||||
|
|
||||||
department-dropdown:
|
department-dropdown:
|
||||||
Name: department
|
Name: department
|
||||||
Title: Department
|
Title: Department
|
||||||
Options: =>EditableOption.department-1, =>EditableOption.department-2
|
Options: =>EditableOption.department-1, =>EditableOption.department-2
|
||||||
|
|
||||||
EditableCheckbox:
|
EditableCheckbox:
|
||||||
checkbox-1:
|
checkbox-1:
|
||||||
Name: checkbox-1
|
Name: checkbox-1
|
||||||
Title: Checkbox 1
|
Title: Checkbox 1
|
||||||
|
|
||||||
checkbox-2:
|
checkbox-2:
|
||||||
Name: checkbox-1
|
Name: checkbox-1
|
||||||
Title: Checkbox 1
|
Title: Checkbox 1
|
||||||
|
|
||||||
EditableCheckboxGroupField:
|
EditableCheckboxGroupField:
|
||||||
checkbox-group:
|
checkbox-group:
|
||||||
Name: check-box-group
|
Name: check-box-group
|
||||||
Title: Check box group
|
Title: Check box group
|
||||||
Options: =>EditableOption.option-3, =>EditableOption.option-4
|
Options: =>EditableOption.option-3, =>EditableOption.option-4
|
||||||
|
|
||||||
EditableEmailField:
|
|
||||||
email-field:
|
|
||||||
Name: email-field
|
|
||||||
Title: Email
|
|
||||||
|
|
||||||
|
EditableEmailField:
|
||||||
|
email-field:
|
||||||
|
Name: email-field
|
||||||
|
Title: Email
|
||||||
|
|
||||||
|
|
||||||
EditableRadioField:
|
EditableRadioField:
|
||||||
radio-field:
|
radio-field:
|
||||||
Name: radio-option
|
Name: radio-option
|
||||||
Title: Radio Option
|
Title: Radio Option
|
||||||
Options: =>EditableOption.option-5, =>EditableOption.option-6
|
Options: =>EditableOption.option-5, =>EditableOption.option-6
|
||||||
|
|
||||||
|
|
||||||
|
EditableFileField:
|
||||||
|
file-field:
|
||||||
|
Name: file-uploader
|
||||||
|
Title: Set file
|
||||||
|
|
||||||
|
|
||||||
ExtendedEditableFormField:
|
ExtendedEditableFormField:
|
||||||
extended-field:
|
extended-field:
|
||||||
Name: extended-field
|
Name: extended-field
|
||||||
Title: Extended Field
|
Title: Extended Field
|
||||||
TestExtraField: Extra Field
|
TestExtraField: Extra Field
|
||||||
TestValidationField: Extra Validation Field
|
TestValidationField: Extra Validation Field
|
||||||
|
|
||||||
|
|
||||||
UserDefinedForm:
|
UserDefinedForm:
|
||||||
basic-form-page:
|
basic-form-page:
|
||||||
Title: User Defined Form
|
Title: User Defined Form
|
||||||
Fields: =>EditableTextField.basic-text
|
Fields: =>EditableTextField.basic-text
|
||||||
EmailRecipients: =>UserDefinedForm_EmailRecipient.recipient-1, =>UserDefinedForm_EmailRecipient.no-html, =>UserDefinedForm_EmailRecipient.no-data
|
EmailRecipients: =>UserDefinedForm_EmailRecipient.recipient-1, =>UserDefinedForm_EmailRecipient.no-html, =>UserDefinedForm_EmailRecipient.no-data
|
||||||
|
|
||||||
form-with-reset-and-custom-action:
|
form-with-reset-and-custom-action:
|
||||||
Title: Form with Reset Action
|
Title: Form with Reset Action
|
||||||
SubmitButtonText: Custom Button
|
SubmitButtonText: Custom Button
|
||||||
ShowClearButton: true
|
ShowClearButton: true
|
||||||
|
|
||||||
validation-form:
|
validation-form:
|
||||||
Title: Validation Form
|
Title: Validation Form
|
||||||
Fields: =>EditableTextField.required-text
|
Fields: =>EditableTextField.required-text
|
||||||
|
|
||||||
custom-rules-form:
|
custom-rules-form:
|
||||||
Title: Custom Rules Form
|
Title: Custom Rules Form
|
||||||
Fields: =>EditableCheckbox.checkbox-2, =>EditableTextField.basic-text-2
|
Fields: =>EditableCheckbox.checkbox-2, =>EditableTextField.basic-text-2
|
||||||
empty-form:
|
empty-form:
|
||||||
Title: Empty Form
|
Title: Empty Form
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user