Jump to:

5516 Posts in 1734 Topics by 1221 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Display the ID

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

Page: 1
Go to End
Author Topic: 760 Views
  • landyman
    Avatar
    Community Member
    11 Posts

    Display the ID Link to this post

    Hello -
    How can I display the ID assigned to the current DataObject in the admin. I've tried adding fields and making them readonly, but the fields never show up; something like:
    $fields->addFieldToTab("Root.Content.Main", new TextField("ID", "Doctor ID"));

    the field doesn't show up. Is there a way I can display that info in the admin?

    Thanks!

    -Aaron

  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    Re: Display the ID Link to this post

    Hi,

    This will show the ID in the list of records and in the record view. I have found that using 'known' names for fields doesn't always work - so in this case I make sure that I am not using the name 'ID' instead 'MyID'.

    public static $summary_fields = array (
       'ID' => 'ID',
       ...
    );

    ...

    function getCMSFields()
    {
       $fields = parent::getCMSFields();

       $fields->insertBefore(new TextField('MyID','MyID',$this->ID),'Name');

       return $fields;
    }

    (note assumes 'Name' in your $db fields!)

    760 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.