简体   繁体   中英

joomla 3 - Store Data to different tables

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM