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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

FileDOM File Title in custom textfield


Reply

327 Views

Avatar
mcocolla

4 July 2012 at 4:57am (Last edited: 4 July 2012 6:00am), Community Member, 4 Posts

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.