Jump to:

5538 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Treemultiselect field in new admin area

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

Page: 1
Go to End
Author Topic: 1411 Views
  • Mo
    Avatar
    Community Member
    508 Posts

    Treemultiselect field in new admin area Link to this post

    Hi All,

    Quick question. I am trying to add a Treemultiselectfield to a new class that extends LeftandMain.

    I have added it in getEditForm as so:

    function getEditForm($id = null) {
       $fields = new FieldSet(
          new HiddenField('ID','id #',$id),
          new TextField('MenuTitle', _t('MenuAdmin.MENUTITLE','Menu Title')),
          new TextField('MenuSlug', _t('MenuAdmin.MENUSLUG','Menu Slug')),
          new TreeMultiselectField('Pages','Pages in Menu','SiteTree')
       );
    }

    The box shows, but the functionality doesnt work. Do I need to include any additional JavaScript to make this work outside of CMS_Main?

    I am currently trying this using the latest 2.4 build, is it just something that is to do with that?

    Cheers,

    Mo

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Treemultiselect field in new admin area Link to this post

    Now tried this in 2.3, same exact thing.

    Anyone got any ideas?

    Mo

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Treemultiselect field in new admin area Link to this post

    No ideas on this anyone? The required Javascript appears to be loading, are they any requirements for the TreeMultiSelectField JS?

    Mo

  • MateuszU
    Avatar
    Community Member
    89 Posts

    Re: Treemultiselect field in new admin area Link to this post

    Hey Mo,
    You have probably checked that already, but are you getting any JS errors when loading that page? Another question is are you on dev or test mode?

  • Arun
    Avatar
    Community Member
    8 Posts

    Re: Treemultiselect field in new admin area Link to this post

    Hey Mo,

    I have created a new module near to Site Content, that is Advertisement. In this module i have created some fields for adding the advertisement. Here is the code

    $fields = new FieldSet(
             new TabSet(   'Root',
                new Tab(_t('AdvertisementAdmin.ADVTDETAILS', 'Advertisement Details xXx'),
                   new HiddenField('ID','id #',$id),
                   new DropdownField('Advertiser', _t('AdvertisementAdmin.ADVERTISER','Advertiser * xXx'), $advertisermap),
                   new TextField('AdTitle', _t('AdvertisementAdmin.ADTITLE','Ad Title xXx'), _t('AdvertisementAdmin.NEWADVERTISEMENT','New Advertisement xXx')),
                   new TextareaField('Html', _t('AdvertisementAdmin.HTMLTEXT','Html/Text xXx'), 8, "", ""),
                   new CheckboxField('Active', _t('AdvertisementAdmin.ACTIVE','Active xXx'), "1"),
                   new TreeMultiselectField('Pages','Pages in Menu','SiteTree')
                )
             )
          );

    So in the above code you can see that i am trying to include a TreeMultiselectField at the last. here i want to load the Site Tree Structure for multiple select. and i want to insert the selected ids in to the same table as ids are comma separated or in any other table with the advertisement id and the page id.

    But in the TreeMultiselectField, it will show up the Site Tree content that i have created.

    So what i need is, i have to show a TreeMultiselectField in the form and i need to multiple check the pages and insert in to the same table where advertisements add or in any other table for storing Added advertisement id along with the selected page ids.

    Could any one help me for this... if so it would be very helpful to me.... any help is much appreciated.

    Thanks and Regards,
    Arun

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Treemultiselect field in new admin area Link to this post

    Hi Arun,

    I still haven't been able to fix this myself. I have had to use a checkboxfield which lists top level pages for the time being as a work around.

    I really don't get this error, all the JavaScript appears to be loaded fine, and there are no JavaScript errors in the console, so I don't understand why this functionality is playing up.

    Anyone have any ideas?

    Mo

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Treemultiselect field in new admin area Link to this post

    AHHA, I have finally managed to fix this. I was getting a JavaScript error from my tree ul in the left pain, that was apparently causing the TreeMultiselectField to not work. Now I have fixed the other error, it is working ok.

    Is anything else on the page causing a JavaScript error Arun?

    Cheers,

    Mo

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