Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] Population dropdown field with enum values

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 5937 Views
  • Tonyair
    Avatar
    Community Member
    81 Posts

    [SOLVED] Population dropdown field with enum values Link to this post

    Hello, I need to populate dropdown field with enum values I tried:

    $this->dbObject('Status')->enumValues(); as described there http://doc.silverstripe.org/dropdownfield

    class ContactPage extends Page {
       static $db = array(
    ...
          "Status" => "Enum('Active, Inactive')",
    ..
       );
       static $can_be_root = false;

       static $has_one = array(
          'Photo' => 'Image'
       );

       function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab("Root.Content.Main",
                      new FieldGroup(
                      ..
                         new DropdownField('Status','Status',singleton('ContactPage')->dbObject('Status')->enumValues()),
    ..

    But still getting error that there're no method enumValues

    ERROR [User Error]: Uncaught Exception: Object->__call(): the method 'enumvalues' does not exist on 'Varchar'
    IN POST /stable/admin/getitem?ID=42&locale=ru_RU&ajax=1
    Line 724 in /home/a2nt/work/www/stable/sapphire/core/Object.php

    [UPDATE]: SOLVED variable 'Status' reserved by SiteTree

    5937 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.