Jump to:

2002 Posts in 1422 Topics by 616 members

Form Questions

SilverStripe Forums » Form Questions » Synchronizing Parent-Child IDs when using HasManyComplexTableField

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

Page: 1
Go to End
Author Topic: 460 Views
  • ScottT
    Avatar
    Community Member
    9 Posts

    Synchronizing Parent-Child IDs when using HasManyComplexTableField Link to this post

    Hello,
    I need some assistance with using a HasManyComplexTableField on a basic form. I have a tabbed form that holds information about a client. The client has many addresses. I am using a HasManyComplexTableField to enter addresses that belong to the client. For the life of us, my coding partner and I have not be able to figure out how to accomplish this.

    The main problem is that when an address is saved, I would like the ClientID to be written to the Address table. I have tried many different ways to set the ClientID manually in the Addresses popup form. For example, I have used fieldset->push() to add it as a hidden field to the fieldset passed to the HasManyCTF to set appropriate ClientID that way. However, the value is often not preserved in the generated Addresses form.

    The form itself subclasses Page. If I create a has_one relationship to Client and a has_many to Addresses, I do get a drop down list in Addresses which allows me to select the right client. However, this is a front-end form and I would like the correct client to be automatically selected. The client that should automatically be associated with the Address HasManyCTF is evidently the one then loaded into the parent form.

    If have also tried using the replaceWith method on the FieldSet object to replace the DropDown ClientID field with a hidden one. However, the value comes through as empty which results in the address being saved with a ClientID of 0.

    Can anyone suggest a way to have the parent and child HasManyCTF synchronized so that when the HasMany is saved it automatically writes the correct ClientID without this having to be set by the user then entering the data?

    This seems like a pretty ordinary use case so I think there must be something very basic I am missing.

    Happy to post code excerpts if this will help.

    Thanks in advance for your help. Have been stumped by this for several days now.

  • ScottT
    Avatar
    Community Member
    9 Posts

    Re: Synchronizing Parent-Child IDs when using HasManyComplexTableField Link to this post

    **BUMP**

    Anyone reading this forum who knows about HasManyCTF???

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