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.

Archive /

Our old forums are still available as a read-only archive.

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

Fatal error: Call to a member function enumValues() on a non-object


Reply


5 Posts   1641 Views

Avatar
ojalà

Community Member, 87 Posts

17 October 2008 at 7:39pm

Hi!
I try to use select form as explain in guide but I have this error:

Call to a member function enumValues() on a non-object in E:\_silverstripe_cms\itesa\mysite\code\Page.php on line 51

Why?

Avatar
Sean

Forum Moderator, 922 Posts

17 October 2008 at 10:26pm

Edited: 17/10/2008 10:27pm

What guide? Where?

What is on that line in the Page.php file as the debug error explains?

Sean

Avatar
ojalà

Community Member, 87 Posts

17 October 2008 at 10:50pm

in my page.php , under the page controller I put this function

function DropForm{
$field = new DropdownField(
'Country',
'Country',
singleton('MyObject')->dbObject('Country')->enumValues()
);
}

and I create MyobjectField.php with this class

class MyObject extends DataObject {
static $db = array(
'Country' => "Enum('New Zealand,United States,Germany','New Zealand')"
);
}

Avatar
ojalà

Community Member, 87 Posts

17 October 2008 at 10:51pm

the guide id here: http://doc.silverstripe.com/doku.php?id=dropdownfield

Avatar
Sean

Forum Moderator, 922 Posts

18 October 2008 at 9:45am

Edited: 18/10/2008 9:45am

MyobjectField.php MUST have a class inside called "MyobjectField". If this isn't the case, SS will not detect the class.

In your case, just rename MyobjectField.php to MyObject.php, run ?flush=1 and you're set.

Sean