Submit 2 forms at once

jh

Member
Hi

Not sure if this can be done like this, but I have a situation where I want 2 forms submitted at once. I believe they can go on the same page however how can they be submitted together in one click?

I wanted the PK created from the first form placed into a FK column in the second table which I guess I can do via PHP but can both forms be submitted at the same time (ie one submit button).

Kind Regards
 
Hi

Thank you for confirming. Just wondered, would you think it could work to perhaps 'mimic' what the second form is doing by setting these values via php on submit instead (so the values are not even stored in the first table)?

Also, is it possible to set the newly created PK/ID from the form as the FK in another table on submit?

Kind Regards
 
Code:
Thank you for confirming. Just wondered, would you think it could work to perhaps 'mimic' what the second form is doing by setting these values via php on submit instead (so the values are not even stored in the first table)?

Yes, I'm sure you could write some custom JS, running at the start of the first form's submission, which grabs inputs from another form and sticks them in hidden form inputs on the first form. So create a form_X.js (where X is the numeric ID of the form being submitted) in ./components/com_fabrik/js ...

Code:
requirejs(['fab/fabrik'], function() {
   Fabrik.addEvent('fabrik.form.submit.start', function(form) {
      // check it's the right form ...
      if (form.id = '123') {
         // your code to grab data from the other form and insert it in hidden elements on this from here
      }
   });
});

Also, is it possible to set the newly created PK/ID from the form as the FK in another table on submit?

You'd need a PHP form submission script, running 'onAfterProcess', which could get the newly created id from $formModel->formData[] and write it out to your other table.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top