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.

General Questions

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

[SOLVED] - ModelAdmin and a DataObject with many files


Reply

6 Posts   1402 Views

Avatar
toddmkimball

2 June 2010 at 4:06am (Last edited: 6 June 2010 1:02am), Community Member, 13 Posts

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

Avatar
swaiba

2 June 2010 at 8:27pm Forum Moderator, 1796 Posts

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

Avatar
toddmkimball

6 June 2010 at 1:01am Community Member, 13 Posts

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

Regards,
Todd

Avatar
adiwidjaja

8 June 2010 at 12:24am Community Member, 14 Posts

Kleine Ergänzung - CSS reicht:

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

Avatar
CHD

3 March 2012 at 2:10am Community Member, 218 Posts

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

Avatar
swaiba

3 March 2012 at 4:38am (Last edited: 3 March 2012 4:39am), Forum Moderator, 1796 Posts

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