mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02: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);
|
$hasOneClass = $this->object->has_one($relationName);
|
||||||
|
|
||||||
if($hasOneClass && singleton($hasOneClass) instanceof Image) {
|
if($hasOneClass && singleton($hasOneClass) instanceof Image) {
|
||||||
if(isset($params['ajaxSafe']) && $params['ajaxSafe']) {
|
$field = new UploadField($relationName, $title);
|
||||||
$field = new ImageField($relationName, $title, $this->value);
|
$field->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
|
||||||
} else {
|
|
||||||
$field = new SimpleImageField($relationName, $title, $this->value);
|
|
||||||
}
|
|
||||||
} elseif($hasOneClass && singleton($hasOneClass) instanceof File) {
|
} elseif($hasOneClass && singleton($hasOneClass) instanceof File) {
|
||||||
if(isset($params['ajaxSafe']) && $params['ajaxSafe']) {
|
$field = new UploadField($relationName, $title);
|
||||||
$field = new FileIFrameField($relationName, $title, $this->value);
|
|
||||||
} else {
|
|
||||||
$field = new FileField($relationName, $title, $this->value);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$titleField = (singleton($hasOneClass)->hasField('Title')) ? "Title" : "Name";
|
$titleField = (singleton($hasOneClass)->hasField('Title')) ? "Title" : "Name";
|
||||||
$map = DataList::create($hasOneClass)->map("ID", $titleField);
|
$map = DataList::create($hasOneClass)->map("ID", $titleField);
|
||||||
|
Loading…
Reference in New Issue
Block a user