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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

MultiSelectField Fix


Go to End


28 Posts   9753 Views

Avatar
jam13

121 Posts

3 March 2010 at 2:55am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

3 March 2010 at 3:47am

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

Avatar
Willr

Forum Moderator, 5523 Posts

3 March 2010 at 2:19pm

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.

Avatar
jam13

121 Posts

3 March 2010 at 11:26pm

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?

Avatar
swaiba

Forum Moderator, 1899 Posts

29 July 2010 at 10:52pm

Edited: 30/07/2010 1:06am

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

Avatar
swaiba

Forum Moderator, 1899 Posts

12 October 2010 at 4:49am

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
Avatar
jam13

121 Posts

13 October 2010 at 10:09pm

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

Avatar
jam13

121 Posts

14 October 2010 at 2:00am

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