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.

Customising the CMS /

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

multilanuage non-object problem


Go to End


3 Posts   2077 Views

Avatar
snaip

Community Member, 181 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, 181 Posts

31 January 2009 at 10:07am

great ! thanks :)