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?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
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?
What guide? Where?
What is on that line in the Page.php file as the debug error explains?
Sean
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')"
);
}
the guide id here: http://doc.silverstripe.com/doku.php?id=dropdownfield
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