Jump to:

10994 Posts in 2728 Topics by 1819 members

All other Modules

SilverStripe Forums » All other Modules » MultiSelectField Fix

Discuss all other Modules here.

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

Page: 1 2 3 4
Go to End
Author Topic: 5518 Views
  • jam13
    Avatar
    121 Posts

    MultiSelectField Fix Link to this post

    For anyone using the MultiSelectField (http://silverstripe.org/multiselectfield-module/) module, I've just submitted a patch to trunk which allows it to be used in the main SiteTree admin area as well as front end and modeladmin. I wasn't actually aware that it didn't work in the SiteTree admin until Aram pointed it out, as I've never had to use it there! Get it here:

    http://svn.gpmd.net/svn/open/multiselectfield/trunk/

    Silverstripe trunk tarball may take a while to catch up.

    Provided I don't get any more reports of problems, I will add a 0.3 release shortly.

    Jamie

  • UncleCheese
    Avatar
    4085 Posts

    Re: MultiSelectField Fix Link to this post

    This is one of my favorite modules. I use it all the time in ModelAdmin, though.. weird.

    I always hack it to accept belongs_many_many relations, too. Might want to add that in. It's only one line, as I remember.

    The only thing I'd like to see is that the entries remember their position when they get pushed back to the first list. The way I've implemented that in the past is that rather than removing the records from the left column, you grey them out, and then when an entry is pushed back, it gets removed from the right, and looks for the element whose text value matches its own, and lights it back up in the left.

    Nice job, though. This needs to be core!!!

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: MultiSelectField Fix Link to this post

    Love it. I keep forgetting that this is a module. Would make dealing with somethings like related content sooo much nicer than a bulky CTF or checkbox set field!.

    I'm probably not the one to make the final call on whether this should be in core or not but +1 for it would be nice to have without requiring a module. Trying to keep sapphire as lean as possible is always the goal but simple, useful fields that fit into core nicely should at least be considered.

  • jam13
    Avatar
    121 Posts

    Re: MultiSelectField Fix Link to this post

    Glad to see people are using it .

    UncleCheese: I'll take a look at the belongs_many_many problem and element ordering, and try to fix them in trunk.

    Incidentally, the reason that it wasn't working in SiteTree admin was down to the field value being serialised into a comma separated list; something that doesn't happen in ModelAdmin. Does anyone know if this is deliberate?

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: MultiSelectField Fix Link to this post

    Hi Jamie,

    Firstly thanks for your great module I use it so much I have integrated it into my main line of code for a basic site!

    I just noticed this thread when I went searching for an answer to something else - just thought I'd mention the Version: [v0.2] works fine with 2.4, but the trunk does not... the list of source items is shown, but the add/remove buttons and the destination list both don't show.

    Many thanks again for the module!

    Barry

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: MultiSelectField Fix Link to this post

    Hi Jamie,

    I didn't realise this was your code (it's Barry from the uk ss meetup)!

    I've now upgraded to 2.4.2 and the multi-select field is no longer working, I don't suppose you might be able to advise on this? I've created a short snip to help reproduce... It was working fine on 2.4.0... I've tried the v0.2 unstable, revision 142 and the GPMD svn access - they all show only the left hand side...

    class MyTestAdmin extends ModelAdmin {
       static $managed_models = array('ObjOne','ObjTwo');

       static $url_segment = 'mytestadmin';
       static $menu_title = 'MyTestAdmin';
    }

    class ObjOne extends DataObject {
       static $db = array('Name' => 'Text');

       static $many_many = array('ObjTwo' => 'ObjTwo');

       function getCMSFields()   {
          $fields = parent::getCMSFields();

          $fields->removeFieldFromTab('Root','ObjTwo');

          $source = DataObject::get('ObjTwo');
          $map = $source ? $map = $source->toDropdownMap('ID','Name') : array();
          $fields->insertAfter(new MultiSelectField("ObjTwo","ObjTwo",$map),'Name');

          return $fields;
       }
    }

    class ObjTwo extends DataObject {
       static $db = array('Name' => 'Text');

       static $belongs_many_many = array('ObjOne' => 'ObjOne');
    }

    Barry

    Attached Files
  • jam13
    Avatar
    121 Posts

    Re: MultiSelectField Fix Link to this post

    I'll take a look at this today if I have time.

  • jam13
    Avatar
    121 Posts

    Re: MultiSelectField Fix Link to this post

    Hi Barry,

    Can't reproduce this at the moment. I've got a 2.4.2 install with latest multiselectfield trunk code (142) and it seems to work fine with a many_many relationship in both the SiteTree (Pages) area and ModelAdmin.

    Is anyone else experiencing any problems with 2.4.x?

    5518 Views
Page: 1 2 3 4
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.