Jump to:

3372 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Confused about DataObjects and GridFields

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

Page: 1
Go to End
Author Topic: 266 Views
  • Spaghetti
    Avatar
    Community Member
    31 Posts

    Confused about DataObjects and GridFields Link to this post

    I've created a StaffPage which lets me add Staff and Departments. BY adding this line below to both staff and department DataObjects I can associate them back to the StaffPage (which obviously, I need to do). They're also associated with each other, so that I can list staff by departments.

    public static $has_one = array(
    "Parent" => "StaffPage",
    );

    My question is, how to I stop this field from being included in the data entry form when I create a department or a staff member (I'm using the GridField object).

    Thanks in advance, let me know if you need my code.

  • kinglozzer
    Avatar
    Community Member
    138 Posts

    Re: Confused about DataObjects and GridFields Link to this post

    Hi Spaghetti,

    In your getCMSFields() function, simply add $fields->removeByName('StaffPageID');. That should do it.

    Loz

  • Spaghetti
    Avatar
    Community Member
    31 Posts

    Re: Confused about DataObjects and GridFields Link to this post

    It was actually ParentID - I found it by inspecting the element but you got me on the right track, thanks very much.

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