1

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 :)

user3755325
  • 79
  • 1
  • 2
  • 9

2 Answers2

1

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

user3755325
  • 79
  • 1
  • 2
  • 9
  • The accepted answer here shows how to do that: http://stackoverflow.com/questions/14738809/write-to-multiple-tables-in-joomla-component – Dennis Heiden Aug 20 '16 at 08:15
0

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.

itoctopus
  • 4,133
  • 4
  • 32
  • 44
  • Hi, thanks for your answer :) the controller has a Save-method? I thought this method is in the model and can be overwritten there? – user3755325 Jul 21 '14 at 18:39
  • Hi and thank you. Well, this form is in the backend and I'm Unsinn the Save-Button in the toolbar. Do I have to edit the templatefile, too? – user3755325 Jul 21 '14 at 19:54