insert data in 2 tables

insert data in 2 tables

UMR5558UMR5558 Posts: 41Questions: 13Answers: 0

Hello everybody.
I have 2 tables T1 and a t2 linked by a foreign key T1_fk_t2.
I create an editor form on my T1 master table with some fields of my t2 table.
I want to be able to create a new record in the my 2 tables from my T1 editor form.
I thought to use an event like .on('preCreate' in my js file or ->on( 'preCreate ' in my php file to creta the row in my t2 table before create row in T1 table.
But every time i have this alert "Foreign key violation: 7 ERREUR: une instruction insert ou update sur la table « T1 »" because the record in my t2 table is not created before.
How can i do this. I really want to use the T1 editor form and only one submit button.
Thanks for your help.
Lionel

Answers

  • UMR5558UMR5558 Posts: 41Questions: 13Answers: 0

    Hello.
    It's working well with a little function call with the preCreate event in my php file.
    You no what ? I m happy.
    Droopy Lionel

  • allanallan Posts: 61,722Questions: 1Answers: 10,108 Site admin

    Just to confirm - have you got it working now? If not, can you post your code please?

    Allan

This discussion has been closed.