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.

All other Modules

Discuss all other Modules here.

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

MultiSelectField Fix

Go to End

28 Posts   5568 Views


3 March 2010 at 2:55am 121 Posts

For anyone using the MultiSelectField ( 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:

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.



3 March 2010 at 3:47am 4085 Posts

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!!!


3 March 2010 at 2:19pm Forum Moderator, 5511 Posts

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.


3 March 2010 at 11:26pm 121 Posts

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?


29 July 2010 at 10:52pm (Last edited: 30 July 2010 1:06am), Forum Moderator, 1796 Posts

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!



12 October 2010 at 4:49am Forum Moderator, 1796 Posts

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();


      $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');


Attached Files

13 October 2010 at 10:09pm 121 Posts

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


14 October 2010 at 2:00am 121 Posts

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?

Go to Top