简体   繁体   English

joomla 3-将数据存储到不同的表

[英]joomla 3 - Store Data to different tables

I am learning Joomla-Development at the Moment and try to Set up a little component. 我目前正在学习Joomla-Development,并尝试设置一些组件。

In the backend there is a form which consists of 2 fields. 在后端,有一个包含2个字段的表单。 Field One should be saved into table 1 - Field 2 should be saved into table 2. 字段1应该保存到表1中-字段2应该保存到表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. 字段1是一个文本字段,应保存到表#__ mycomponent_table1中,字段2是一个Textarea,应保存到表#__ mycomponent_table_2中。

Table 1 already has got a overwritten store()-method. 表1已经有一个被覆盖的store()方法。 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. 您将需要覆盖控制器中的save方法-在该方法中,您需要将数据手动保存到数据库中。

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. 这将确保您的网站调用控制器中的“提交”功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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