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.

Customising the CMS /

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

multilanuage non-object problem


Go to End
Reply


3 Posts   1330 Views

Avatar
snaip

Community Member, 180 Posts

31 January 2009 at 8:06am

Edited: 31/01/2009 8:55am

i have a problem when i want to translate page which inlude DropdownField


"Fatal error: Call to a member function toDropdownMap() on a non-object in /home/wilgocki/domains/wilgocki.net/public_html/silverstripe/mysite/code/TourPage.php on line 76"


Avatar
UncleCheese

Forum Moderator, 4102 Posts

31 January 2009 at 9:50am

Somewhere in TourPage.php, you're doing something like this:

DataObject::get("Something")->toDropDownMap();

Unless you're 100% sure that "Something" will not return a null set, you shouldn't run a method on that output. A better practice is this:

$stuff = DataObject::get("Something");
$map = $stuff? $stuff->toDropdownMap() : array();

return new DropdownField('Name','Title', $map);

Avatar
snaip

Community Member, 180 Posts

31 January 2009 at 10:07am

great ! thanks :)