Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » FileDOM File Title in custom textfield

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 302 Views
  • mcocolla
    Avatar
    Community Member
    4 Posts

    FileDOM File Title in custom textfield Link to this post

    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.

    302 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.