mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fixing broken docs on setting allowed extensions on a FileField
Refers to an invalid variable, and is overriding the entire Upload, which isn't necessary.
This commit is contained in:
parent
fedad00e00
commit
6267d2e51e
@ -534,10 +534,8 @@ own validation.
|
|||||||
// Limit extensions on upload (in PHP)
|
// Limit extensions on upload (in PHP)
|
||||||
// Markup contains <input type="file" data-allowed-extensions="jpg,jpeg,gif" />
|
// Markup contains <input type="file" data-allowed-extensions="jpg,jpeg,gif" />
|
||||||
$exts = array('jpg', 'jpeg', 'gif');
|
$exts = array('jpg', 'jpeg', 'gif');
|
||||||
$validator = new Upload_Validator();
|
$fileField = FileField::create('MyFile');
|
||||||
$validator->setAllowedExtensions($exts);
|
$fileField->getValidator()->setAllowedExtensions($exts);
|
||||||
$upload = Upload::create()->setValidator($validator);
|
|
||||||
$fileField = FileField::create('MyFile')->setUpload(new);
|
|
||||||
$fileField->setAttribute('data-allowed-extensions', implode(',', $exts));
|
$fileField->setAttribute('data-allowed-extensions', implode(',', $exts));
|
||||||
|
|
||||||
Note that these examples don't have any effect on the client as such, but are
|
Note that these examples don't have any effect on the client as such, but are
|
||||||
|
Loading…
Reference in New Issue
Block a user