Jump to:

3429 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Show Tab or Field after Saving - DataObject

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

Page: 1
Go to End
Author Topic: 383 Views
  • Phils
    Avatar
    Community Member
    9 Posts

    Show Tab or Field after Saving - DataObject Link to this post

    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

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Show Tab or Field after Saving - DataObject Link to this post

    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

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: Show Tab or Field after Saving - DataObject Link to this post

    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.

  • Phils
    Avatar
    Community Member
    9 Posts

    Re: Show Tab or Field after Saving - DataObject Link to this post

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

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

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