I'm trying to use a variable that has many Images for a page banner using the code below:
BannerFile.php:
class BannerFile extends Image {
static $has_one = array (
'Pages' => 'Page'
);
}
Page.php
public static $has_many = array(
'BannerFiles' => 'BannerFile'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Thumbnail", new FileUploadField('Thumbnail', 'Thumbnail'));
$fields->addFieldToTab("Root.Content.Banners", new MultipleImageUploadField('BannerFiles','Upload several banner files'));
//...
return $fields;
}
On seemingly random pages I get the error:
[User Error] Couldn't run query: SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "BannerFile"."PagesID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" LEFT JOIN "BannerFile" ON "BannerFile"."ID" = "File"."ID" WHERE ("File"."ClassName" IN ('Image','BannerFile','Image_Cached')) AND (ID = '22') ORDER BY SortOrder ASC LIMIT 1 Column 'ID' in where clause is ambiguous
GET /site/3d-scanners/accessories/?flush=1
Line 536 in G:\localhost\site\sapphire\core\model\MySQLDatabase.php
The images are shown correctly for the test pages where I assigned images too. On random other pages (both with and without banner images added) I get the above error.
If I change Image to File in the BannerFile class the error disappears.
BannerFile.php:
class BannerFile extends File {
static $has_one = array (
'Pages' => 'Page'
);
}
Can I only use the File class and not the Image class with the new Uploadify Class? Or is there a bug somewhere else?