Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » DataObjectManager with optional files

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: 815 Views
  • nafetsch
    Avatar
    Community Member
    15 Posts

    DataObjectManager with optional files Link to this post

    Hey Guys,

    Need a little help.

    I want to use the DataObjectManager because I have a lot of text fields and NOT EVERTIME A FILE. Or is it possible to use the FileDataObjectManager with optional Fileupload?

    Here is my code:

    <?php

    class DataLinks extends DataObject
    {
       static $db = array (
          'Author' => 'Text',
          'Quote' => 'HTMLText'
       );

       static $has_one = array (
          'DataLinks' => 'Links',
          'Attachment' => 'File',
       
       );

       public function getCMSFields_forPopup()
       {
          return new FieldSet(

             new TextField('Author'),
             new TextareaField('Quote'),
             new FileIFrameField('Attachment')
             
          );
       }
    }

    --------------------- and ------------------

    class Links extends Page {

       static $has_many = array
       (
       'DataLinkss' => 'DataLinks',
       
    );

    function getCMSFields() {
       $fields = parent::getCMSFields();
       $fields->addFieldToTab("Root.Content.Testimonials", new DataObjectManager(
             $this,
             'DataLinkss',
             'DataLinks',
             'Attachment',
             array('Date' => 'Date','Author'=>'Author','Quote' => 'Quote'),
             'getCMSFields_forPopup'
          ));
       return $fields;
    }
    }

    class Links_Controller extends Page_Controller {
    }

    Here is the error:
    [User Error] Couldn't run query: SELECT "DataLinks"."ClassName", "DataLinks"."Created", "DataLinks"."LastEdited", "DataLinks"."Author", "DataLinks"."Quote", "DataLinks"."DataLinksID", "DataLinks"."AttachmentID", "DataLinks"."ID", CASE WHEN "DataLinks"."ClassName" IS NOT NULL THEN "DataLinks"."ClassName" ELSE 'DataLinks' END AS "RecordClassName" FROM "DataLinks" WHERE ((getCMSFields_forPopup) AND ("DataLinksID" = '100')) ORDER BY Created DESC LIMIT 10 OFFSET 0 Unknown column 'getCMSFields_forPopup' in 'where clause'

    Plz help...

  • UncleCheese
    Avatar
    4085 Posts

    Re: DataObjectManager with optional files Link to this post

    Yeah, I ran into the same problem on a recent project, and I'm going to be adding in that feature to that FDOM has two action buttons -- "upload" and "add".. That way a user could provide an uploaded resource or just hit "Add" if they want to use an external link.

  • nafetsch
    Avatar
    Community Member
    15 Posts

    Re: DataObjectManager with optional files Link to this post

    hey thx for your anther... but i am not shure if i explained my problem the right way:

    I want to use the nice DataObjectManager Module with the possibilty to add files. but not every entry has a file.

    Do you have a solution for me?

  • UncleCheese
    Avatar
    4085 Posts

    Re: DataObjectManager with optional files Link to this post

    Well you could always just use a regular DOM..

    815 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.