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.

Data Model Questions /

Show Tab or Field after Saving - DataObject


Reply


4 Posts   514 Views

Avatar
Phils

Community Member, 10 Posts

29 November 2013 at 1:15am

Edited: 29/11/2013 1:15am

Hi everybody,

I got a DataObject with some has_many Relations. I know, that the DataObject has to be saved first, before you can add the related Object with a Gridfield (like you have to save first before you can add Images with a Uploadfield).

My Question is, if I can hide the Gridfield and/or the Tab where my Gridfield is in until the DataObject is saved. So that the Editor doesn't get confused.

How does the UploadField work, which first shows a message and after saving the Dataobject shows the possibility to Upload?

Thanks in advance,
Philip

Avatar
martimiz

Forum Moderator, 1132 Posts

5 December 2013 at 1:13am

i don't know if this would work, but just maybe you could hide the field in the DataObjects getCMSFields() if the $this->ID is empty?

Martine

Avatar
zenmonkey

Community Member, 532 Posts

7 December 2013 at 3:58pm

I'm pretty sure as of 3.1.x creating a new DataObject creates a draft object so you can actual do relations before saving at least for images. I wrap the fields I want to hide in if $this->ID != 0 since the draft object actually has an ID of 0.

Avatar
Phils

Community Member, 10 Posts

11 January 2014 at 12:55am

Thank you both.
Everything works fine now.
Wrapped my Tabs and fields in:

if ($this->ID != 0){
}