mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Using new UploadField in ForeignKey scaffolding, replacing deprecated ImageField/FileField classes
This commit is contained in:
parent
23bd11281d
commit
c3f4db1d7d
@ -31,17 +31,10 @@ class ForeignKey extends Int {
|
||||
$hasOneClass = $this->object->has_one($relationName);
|
||||
|
||||
if($hasOneClass && singleton($hasOneClass) instanceof Image) {
|
||||
if(isset($params['ajaxSafe']) && $params['ajaxSafe']) {
|
||||
$field = new ImageField($relationName, $title, $this->value);
|
||||
} else {
|
||||
$field = new SimpleImageField($relationName, $title, $this->value);
|
||||
}
|
||||
$field = new UploadField($relationName, $title);
|
||||
$field->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
|
||||
} elseif($hasOneClass && singleton($hasOneClass) instanceof File) {
|
||||
if(isset($params['ajaxSafe']) && $params['ajaxSafe']) {
|
||||
$field = new FileIFrameField($relationName, $title, $this->value);
|
||||
} else {
|
||||
$field = new FileField($relationName, $title, $this->value);
|
||||
}
|
||||
$field = new UploadField($relationName, $title);
|
||||
} else {
|
||||
$titleField = (singleton($hasOneClass)->hasField('Title')) ? "Title" : "Name";
|
||||
$map = DataList::create($hasOneClass)->map("ID", $titleField);
|
||||
|
Loading…
x
Reference in New Issue
Block a user