Jump to:

22976 Posts in 11702 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] Trouble getting the DropDownField & array to work in getCMSFields_Popup

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 2
Go to End
Author Topic: 1600 Views
  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: [SOLVED] Trouble getting the DropDownField & array to work in getCMSFields_Popup Link to this post

    Use :

    static $default_sort = 'LastName ASC';

    in your DataObject.

  • RichMcNabb
    Avatar
    Community Member
    34 Posts

    Re: [SOLVED] Trouble getting the DropDownField & array to work in getCMSFields_Popup Link to this post

    Legend!! I spent a few hours trying to figure that out yesterday and with your help done in under an hour - thanks heaps

    Code below:

    <?php

    class Staff extends DataObject {

    static $default_sort = 'LastName ASC';

    static $db = array(
    'FirstName' => 'Text',
    'LastName' => 'Text',
    'Email' => 'Text',
    'Location' => "Enum('Wellington,Auckland,Christchurch,London','Wellington')",
    'JobTitle' => 'Text',
    'JobDescription' => 'Text',
    );

    static $has_one = array(
    'Page' => 'StaffPage',
    'StaffProfileImage' => 'CustomImage',

    );
    static $fields = array(
    'FirstName' => 'FirstName',
    'LastName' => 'LastName',
        'Location' => 'Location',
    'Email' => 'Email',
    'JobTitle' => 'JobTitle',
    'JobDescription' => 'JobDescription',
    );

    public function getCMSFields_forPopup() {
    $fields = new FieldSet();

    $fields->push(new TextField('FirstName', 'First name'));
    $fields->push(new TextField('LastName', 'Last name'));
    $fields->push(new DropDownField('Location', 'Location', singleton('Staff')->dbObject('Location')->enumValues()));
    $fields->push(new TextField('Email'));
    $fields->push(new TextField('JobTitle', 'Job Title'));
    $fields->push(new TextareaField('JobDescription', 'Job Description - write a couple of paragraphs to describe your role at CDP.'));
    $fields->push(new ImageField('StaffProfileImage', 'Staff profile image'));

       return $fields;
       }

    }
    ?>

    1600 Views
Page: 1 2
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.