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 /

multilanuage non-object problem


Reply


3 Posts   1076 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

[URL=http://imageshack.us][/URL]
[URL=http://g.imageshack.us/img88/translation1fk0.jpg/1/][/URL]

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

[URL=http://imageshack.us][/URL]
[URL=http://g.imageshack.us/img510/translation2bg1.jpg/1/][/URL]

Avatar
UncleCheese

Forum Moderator, 4094 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 :)