joomla 3 - Store Data to different tables

651 views Asked by At

I am learning Joomla-Development at the Moment and try to Set up a little component.

In the backend there is a form which consists of 2 fields. Field One should be saved into table 1 - Field 2 should be saved into table 2.

Field 1 is a text-field, which should be saved into table #__mycomponent_table1, field 2 is a Textarea, which should be saved into table #__mycomponent_table_2.

Table 1 already has got a overwritten store()-method. How can I Save the data of the field into another table?

Thanks in Advance :)

2

There are 2 answers

2
itoctopus On

You will need to override the save method in the controller - in that method you will need to save the data manually to the database.

Edit:

In your template file, add:

<?php echo JHtml::_('form.token'); ?>
<input type="hidden" name="option" value="com_yourcomponent" />
<input type="hidden" name="task" value="yourview.submit" />

This will ensure that your website calls the "submit" function in the controller.

1
user3755325 On

I solved it by overwriting the save-method in the model. You can call a second table and save the data after binding it.