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.

Archive /

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

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

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


Go to End


5 Posts   2400 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

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