21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 215 Views |
-
Folder field problem

2 May 2012 at 8:33am
Hi guys,
I'm experiencing a problem with creating a field (for a Page type class) to select a folder from assets (e.g. gallery).
As I've read and looked up in a module (ImageGallery basic) to make such a field one should use TreeDropdownField.
But when it comes to the real deal - the dropdown shows "loading..." and error pops up "Error getting data".
This is the implementation i used (folder option in ImageGallery basic is not working for me as well):class TestPage extends Page {
static $db = array();static $has_one = array(
"SourceFolder" => "Folder"
);
function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab("Root.Content.Main", new TreeDropdownField("SourceFolderID", "Source Folder", "Folder"));
return $fields;
}
}Using version 2.4.7.
Thanks in advance. I'll be contributing some useful modules/widgets if you help me on this
-
Re: Folder field problem

2 May 2012 at 3:39pm
Hi Ragna,
I'm not too familiar with Treedropdownfield, but....
This is from the Treedropdown file:
* @param sourceObject The object-type to list in the tree. Must be a 'hierachy' object. Alternatively,
* you can set this to an array of key/value pairs, like a dropdown source. In this case, the field
* will act like show a flat list of tree items, without any hierachy.(Just got a text to leave work so will have to be quick)
$folder = DataObject::get('File', ClassName = 'Folder'); // and any other parameters you may need
$folder->toArray();function getCMSFields(){
$fields = parent::getCMSFields();$fields->addFieldToTab("Root.Content.Main", new TreeDropdownField("SourceFolderID", "Source Folder", $folder));
return $fields;
}Luck!
| 215 Views | ||
|
Page:
1
|
Go to Top |


