How can i do an editor form on two tables?

How can i do an editor form on two tables?

UMR5558UMR5558 Posts: 41Questions: 13Answers: 0

Hello everybody.
I have 2 tables T1 and t2 linked by a join (foreign key from T1.t2_id to t2.id). I created 2 editor forms for ech tables. In the T1 editor form i have a select type field for selecting a t2 id.
But I wish I could create a new t2 id from the T1 editor form if in the select the t2 id is not present.
How i do something like that. Is it possible to call and insert the t2 editor form inside the T1 editor form?
how would you do this ?
Thanks for your help and have a nice day
Lionel

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406

    "But I wish I could create a new t2 id from the T1 editor form if in the select the t2 id is not present."

    That is not easy with Data Tables. Here is something similar: Adding options dynamically in case they don't exist in the options table. Maybe that gives you some hints.

    https://datatables.net/forums/discussion/47399/add-options-in-database#latest

  • UMR5558UMR5558 Posts: 41Questions: 13Answers: 0

    Hello everybody and thanks rf1234 for your answer.
    I don't only want to add a new id in the select ok the T1 table. If the t2 id is not present in tne select, I need to add 'all the data' in the t2 table by inserting a sub-form (for the t2 data) in the T1 editor form.
    Do you think is possible ? How insert the t2 editor form in the principal T1 editor form?
    Is there another way to do something like that maybe remplacing the T1 editor form by the t2 editor form and come back to the T1 editor form without erasing the values ​​already entered.

    Thanks a lot
    Lionel

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    Answer ✓

    Currently, the only way to do this would be to use a preEdit or preCreate server-side event and write into the second table manually, then allow Editor to write into the first table.

    The ability to do what you are looking for is something we are actively looking into providing in future.

    Allan

  • UMR5558UMR5558 Posts: 41Questions: 13Answers: 0

    Thanks Allan
    Actually i test preCreate combine with add function in the editor(for creating a sub form). First steps are encouraging.
    I try to manipulate events on different fields for create new fields show or hide others.
    Thanks a lot everybody

This discussion has been closed.