Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

FileDOM File Title in custom textfield


Go to End


1067 Views

Avatar
mcocolla

Community Member, 4 Posts

4 July 2012 at 4:57am

Edited: 04/07/2012 6:00am

I'm using FileDOM to add a document library to a site. I've got the system setup with DOM and Uploadify so that I can add files and then continue to fill in each files custom information which includes a description text field and category select field the document.

I know the assets system renames the physical file if there are spaces when it uploads the file and uses the original file name as the file title. Is it possible to populate the description field with the file title or perhaps expose File.Title to DOM so they can either accept the default title as the description or edit it?

This is the dataobject code:

class LibraryTab extends DataObject {
	static $db = array(
		'Description' => 'Text',
		'Category' => "Enum('Air, Metals, Organics, Wet Chemistry')"
	);
	static $has_one = array(
		'LibraryFile' => 'File',
		'LibraryPage' => 'LibraryPage'
	);
	public function getCMSFields_forPopup(){
		return new FieldSet(
			new TextField('Description','File Description',$this->File.Title),
			new DropdownField('Category','File Category', singleton('LibraryTab')->dbObject('Category')->enumValues())
		);
	}
}

I can see that the upload happens and the assets are added to the table and then their IDs are stored to used as you continue through the rest of the form fields. Is there a way to get that ID as it generates each files form view and use it to call something like File::get()->byID(#) and use the result to populate the description field?

Any help would be appreciated.

Thank you.