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   1475 Views

Avatar
toddmkimball

Community Member, 13 Posts

2 June 2010 at 4:06am

Edited: 06/06/2010 1:02am

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

Forum Moderator, 1808 Posts

2 June 2010 at 8:27pm

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

Community Member, 13 Posts

6 June 2010 at 1:01am

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

Regards,
Todd

Avatar
adiwidjaja

Community Member, 14 Posts

8 June 2010 at 12:24am

Kleine Ergänzung - CSS reicht:

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

Avatar
CHD

Community Member, 218 Posts

3 March 2012 at 2:10am

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

Avatar
swaiba

Forum Moderator, 1808 Posts

3 March 2012 at 4:38am

Edited: 03/03/2012 4:39am

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