1 Form - Save in 2 Different Tables

tiagovareta

Member
Hello!!!

I have a situation to make an application in Fabrik! I have several tables with data users, and wanted to have the data by "Tabs" (as I have in the images below).

In the images below, I created a list / form and two groups of fields connected to the same form and I enabled pagination. Apparently it's the way I want, except the data recording. This way is to record all on the same table (utilizadores) and I want to record the "Tab 1" in the table utilizadores and the "Tab 2" in the table morada. Thus adding a second address also will create duplicate user record, I want to just go get the user id and create address and this is listed in the "Table 2".

Table "utilizadores":
Id | Nome | N?mero | Nacionalidade

Table "morada":
Id | Id Utilizador | Morada

Will can help me solve this?

Fabrik01.png


Fabrik02.png
 
You may use php form plugin for that:
http://fabrikar.com/forums/index.ph...e-a-form-s-field-with-the-records-primary-key

Set process script on End of form submission


So I keep what I did and Users Form Plugins tab, choose PHP and place:

$db= JFactory::getDbo();
$query=$db->getQuery(true);
$query->insert('tablename')->set('field = '.$db->quote('bar'))
->set('field2 = '.$db->quote('{tablename___elementname}');
$db->setQuery($query);
$db->execute();
$id=$db->insertid();

// Update form data with insert id
$formModel->updateFormData('tablename___elementname2',$id);

Will could help me, show me where and what data place?

This put to the code data from the utilizadores table?
$db= JFactory::getDbo();
$query=$db->getQuery(true);
$query->insert('tablename')->set('field = '.$db->quote('bar'))
->set('field2 = '.$db->quote('{tablename___elementname}');
$db->setQuery($query);
$db->execute();
$id=$db->insertid();

This put to the code data from the mroada table?
// Update form data with insert id
$formModel->updateFormData('tablename___elementname2',$id);
 
This code must use to create new record for new created address.
Records in table morada (has to be databasejoined) should be created when save form with tabs.
 
This code must use to create new record for new created address.
Records in table morada (has to be databasejoined) should be created when save form with tabs.

I want to thank their availability and help. But as I'm starting to use Fabrik, I could not get the tips you said. I chose to purchase a subscription to see if I explain in detail, I have the project stopped because of this.
Thank you so much!!!
 
I'm a little confused.

If you've set that second group to "repeat", then it is already using a second table, as a "one to many" join. So each "Morada" will be a separate row in that table.

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

Thank you.

Staff online

Members online

Back
Top