Jump to:

22977 Posts in 11806 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] - ModelAdmin and a DataObject with many files

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1299 Views
  • toddmkimball
    Avatar
    Community Member
    13 Posts

    [SOLVED] - ModelAdmin and a DataObject with many files Link to this post

    Has anyone had any luck with the ModelAdmin generating an interface for a DataObject with more than one file field?

    code so far:

    class FeaturedInitiatives extends DataObject
    {
    static $db = array (
          'Title' => 'Text',
          'Description' => 'HTMLText'
       );

       static $has_one = array (
          'Thumb' => 'File',
          'ShadedThumb' => 'File',
          'MainImage' => 'File'
       );

       public function getCMSFields()
       {
          return new FieldSet(
             new TextField('Title'),
             new HTMLEditorField('Description'),
             new FileIFrameField('Thumb'),
             new FileIFrameField('ShadedThumb'),
             new FileIFrameField('MainImage')
          );
       }
    }

    The UI, after saving an object, lacks and scrollbar and only displays a single file field.
    Also, I tried this with ImageFields and had no luck either.

    Regards,
    Todd

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: [SOLVED] - ModelAdmin and a DataObject with many files Link to this post

    Hi Todd,

    I cannot explain it, but I can fix it for you... (assuming you use ss 2.4.0 as I have tested with that)

    add this to your YourModelAdmin.php :-

    public function init()
    {
       parent::init();
       Requirements::javascript('mysite/javascript/modeladmin.js');
    }

    this is the contents of mysite/javascript/modeladmin.js :-

    jQuery('#ModelAdminPanel').css('overflow', 'auto');

    Barry

  • toddmkimball
    Avatar
    Community Member
    13 Posts

    Re: [SOLVED] - ModelAdmin and a DataObject with many files Link to this post

    Thanks Barry, that worked as stated and solved the issue. Why didn't I think of that...

    Regards,
    Todd

  • adiwidjaja
    Avatar
    Community Member
    14 Posts

    Re: [SOLVED] - ModelAdmin and a DataObject with many files Link to this post

    Kleine Ergänzung - CSS reicht:

    public function init() {
    parent::init();
    Requirements::customCSS("#ModelAdminPanel {overflow:auto;}");
    }

  • CHD
    Avatar
    Community Member
    217 Posts

    Re: [SOLVED] - ModelAdmin and a DataObject with many files Link to this post

    why hasnt this been applied to the latest SS versions? it seems like a pretty obvious bug.

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: [SOLVED] - ModelAdmin and a DataObject with many files Link to this post

    http://groups.google.com/group/silverstripe-dev/browse_thread/thread/1676366a087164c5#

    seemed aproriate as I got this email in the digest at the tiem of reading this

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