Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » ModelAdmin: Unable to scroll

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

Page: 1
Go to End
Author Topic: 575 Views
  • merrick_sd
    Avatar
    Community Member
    89 Posts

    ModelAdmin: Unable to scroll Link to this post

    has anyone come accross this.

    I have used model Admin to display and edit a DataObject but I cannot scroll.

    Im using Firefox

    code
    GlobalAdmin.php
    --------------------------------------
    class GlobalAdmin extends ModelAdmin {

       public static $managed_models = array(
          'FooterIcon', 'GlobalBanner', 'FootNote', 'ccswlogin','Office'//'NavStyle'
       );

       static $url_segment = 'Global'; // will be linked as /admin/products
       static $menu_title = 'Global';

    }
    ---------------------------------------

    Office.php
    <?php

    class Office extends DataObject {

       static $db = array(
       'MainOffice' => 'Boolean',
       'CompanyReg' => 'Text',
       'VATNo' => 'Text',
       'Title' => 'Text',
       'Address1' => 'Text',
       'Address2' => 'Text',
       'Address3' => 'Text',
       'Address4' => 'Text',
       'City' => 'Text',
       'Country' => 'Text',
       'Postcode' => 'Text',
       'Tel' => 'Varchar',
       'Fax' => 'Varchar',
       'Email' => 'Varchar',
       'OfficeExtra' => 'HTMLText'
       );
       
       static $singular_name = 'Office';
       static $plural_name = 'Offices';
       
       
       static $has_one = array(
       'SiteTree' => 'SiteTree',
       'officepagelink' => 'SiteTree',

       );
       
          // Model Admin utilities
       static $searchable_fields = array(
          'Title',
          'Postcode'
          //'ID',
          //'helpline'
    );
       
       
       static $summary_fields = array(
    'MainOffice',
       'Title',
       'Address1',
       'City',
       'Postcode',
       );
       
          function getCMSFields(){
       $source = DataObject::get("SiteTree");
       $optionArray = $source->toDropDownMap($index = 'ID', $titleField = 'Title', "--- select page ---", $sort = "Sort");
       if($source) foreach( $source as $page ) {
             $optionArray[$page->ID] = $page->MenuTitle;
          }
       
          $fields = new FieldSet(
          //new DropdownField("AllSameASID","Set Links Same As",$optionArray),
           new CheckBoxField('MainOffice', "Tick to mark as MainOffice"),
           new TextField('CompanyReg', 'Companys House Reg eg: Registered in England 00000','Email'),
               new TextField('VATNo', 'VAT No eg:GB 383 8602 20
               ', 'Email'),
             new TextField('Title', 'Office Name'),
             new TextField('Address1', 'Address line1'),
                new TextField('Address2', 'Address line2'),
                new TextField('Address3', 'Address line3'),
                new TextField('Address4', 'Address line4'),
                   new TextField('City', 'City'),
                      new TextField('Country', 'Country'),
                         new TextField('Postcode', 'Postcode'),
                            new TextField('Tel', 'Tel'),
                               new TextField('Fax', 'Fax'),
                                  new EmailField('Email', 'Email'),
                                  
                                  new HtmlEditorField('OfficeExtra', 'ExtraContent'),   
                         new DropdownField("officepagelinkID","Link To Page",$optionArray),
                   
                      new LiteralField (
                      $name = "literalfield",$content = "<p>Remember to click Save / Add</p>"
                      )
             
          );

       return $fields;
       }
       
       
       function VarOfficeLink() {

          $dos = new DataObjectSet();
       
             $fieldname = "officepagelinkID";
             if($this->$fieldname > 0) {
                if($page = DataObject::get_by_id("SiteTree", $this->$fieldname - 0)) {
                   $dos->push($page);
                }
             }
          
          return $dos;
       }

       
       
    }

    ?>

    This works in the Admin, but I can't scroll down to edit other fields.

    Any advice appreciated

    picture attached

    Attached Files
  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: ModelAdmin: Unable to scroll Link to this post

    Hi,

    You are treating model admin like a page, this is wasting your time. ModelAdmin scafolds the fields so you don't have to - all you need to is remove what you don't want (removebyname), change what needs changing (replacefield) and add new things (insertbefore,insertafter).

    It is likely sorting the above will sort your problem.

  • merrick_sd
    Avatar
    Community Member
    89 Posts

    Re: ModelAdmin: Unable to scroll Link to this post

    When you say Im treating it as a Page.. do you mean i don't need. function getCMSFields()

    I haven't extended Page .. I have extended DataObject and ModelAdmin

    class Office extends DataObject {

    and

    class GlobalAdmin extends ModelAdmin {

    I did try

    function getCMSFields(){

    $fields = parent::getCMSFields();
          return $fields;
       }

    Doesn't solve as yes the fields are still rendered but still have same problem in cannot scroll, also fields aren't singular they have drag handles now.

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: ModelAdmin: Unable to scroll Link to this post

    well - yes you don't need to define getCMSfields - that is the great thing about modeladmin

    now if you do want to checnge/add things use the functions above

    so if you take the getCMSFields away and it still fails then you problem is not in the dataobject fields, or getCMSFields then is it? so I would say it is not possible to advise becasue *something else* is causing the issue...

  • merrick_sd
    Avatar
    Community Member
    89 Posts

    Re: ModelAdmin: Unable to scroll Link to this post

    haha

    I found if I don't use a HTMLEditorField i always get scrollbars.

    $fields->addFieldToTab('Root.Main',new HtmlEditorField('OfficeExtra'));

    so need to figure out how i can have a html tnymce field within model admin or just avoid them i guess

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: ModelAdmin: Unable to scroll Link to this post

    This is very strange as I use TinyMCE in ModelAdmin all the time with no issue - have you done any hacking or is this a clean install?

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