Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

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.

Data Model Questions /

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

Confused about DataObjects and GridFields


Go to End


3 Posts   879 Views

Avatar
Spaghetti

Community Member, 32 Posts

21 March 2013 at 4:49am

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.

Avatar
kinglozzer

Community Member, 187 Posts

21 March 2013 at 5:48am

Hi Spaghetti,

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

Loz

Avatar
Spaghetti

Community Member, 32 Posts

21 March 2013 at 10:38pm

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