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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

[SOLVED]Latest revision fails on Sort field


Go to End


5 Posts   1146 Views

Avatar
NickJacobs

Community Member, 148 Posts

29 January 2010 at 10:07am

Edited: 29/01/2010 10:55am

Hi, I've had a site running sweet with the DOM, and upgraded it to rev347 and now I get errors in the CMS (Undefined offset error). I've tracked it down to the Sort parameter...with anything in there I get the error....with no sort parameter specifed it works fine.

code is:


public function getCMSFields()
	{
		$f = parent::getCMSFields();
		$manager = new DataObjectManager(
			$this, // Controller
			'Endangereds', // Source name
			'Endangered', // Source class
			array('Family' => 'Family', 'Genus' => 'Genus','Species' => 'Species','CommonName' => 'CommonName'), // Headings
			'getCMSFields_forPopup' // Detail fields function or FieldSet
			,""// Filter clause
			,"Genus"// Sort clause
			// Join clause
		);
		
		$f->addFieldToTab("Root.Content.EndangeredList", $manager);
		
		return $f;
	}

data object is:

class Endangered extends DataObject
{
	static $db = array (
		'Family' => 'Text',		
		'Genus' => 'Text',
		'Hybrid' => 'Text',
		'Species' => 'Text',		
		'Infraspecific' => 'Text',
		'Cultivar' => 'Text',
		'CultivarGroup' => 'Text',
		'Synonym' => 'Text',
		'CommonName' => 'Text',
		'Continent' => 'Text',
		'GeoRegion' => 'Text',
		'Herbarium' => 'Boolean',
		'IUCNCode' => 'Text',
		'Fieldx1' => 'Text',
		'Var' => 'Text'
	);
	
	static $has_one = array (
		'EndangeredPage' => 'EndangeredPage',
		'PlantImage' => 'Image'
	);
	
	static $searchable_fields = array( 
	'Family','Genus','Species','CommonName'
	);
	
	
	public function getCMSFields_forPopup()
	{
		return new FieldSet(
			
			new TextField('Family'),
			new TextField('Fieldx1'),
			new TextField('Genus'),
			new TextField('Hybrid'),
			new TextField('Species'),
			new TextField('Var'),
			new TextField('Infraspecific'),
			new TextField('Cultivar'),
			new TextField('CultivarGroup'),
			new TextField('Synonym'),
			new TextField('CommonName'),
			new TextField('Continent'),
			new TextField('GeoRegion'),
			new CheckboxField('Herbarium','In herbarium?'),
			new TextField('IUCNCode'),
						
			new ImageField("PlantImage", "Plant Image")
		);
	}
}

If I remove Genus from the sort it works fine.....
running ss2.3.5 (stable) and DOM,SWFupload, Image_Gallery rev347

any ideas??

Avatar
UncleCheese

Forum Moderator, 4102 Posts

29 January 2010 at 10:20am

Hi, Nick,

Could you paste the exact error, please?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

29 January 2010 at 10:22am

Oh, you might want to try "Genus ASC" for your sort clause. Let me know if that fixes anything.

Avatar
NickJacobs

Community Member, 148 Posts

29 January 2010 at 10:28am

Ha, yes thats cracked it! Is this a recent change (explicit sort direction required)?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

29 January 2010 at 10:51am

Yeah, stupid me. I'll be checking in a patch momentarily.