简体   繁体   English

Joomla Form插件是否可以创建表格并将表格数据保存到该表格?

[英]Is it possible for a Joomla Form plugin to create a table and save form data to that table?

I am working on creating a Joomla based web service that is easy to use. 我正在创建一个易于使用的基于Joomla的Web服务。 The end goal is to allow customers the ability to manage the site from the front-end with no back-end (administrator) access. 最终目标是使客户能够从前端管理站点,而没有后端(管理员)访问权限。 To accomplish this task I am using K2 that has existing front-end editing. 为了完成此任务,我使用具有现有前端编辑功能的K2。 Then behind the scenes we will provide technical support. 然后在幕后我们将提供技术支持。 Essentially, non-techy customers can easily manage their site, with us managing the tech side of things. 基本上,非技术客户可以通过我们管理技术方面的内容轻松管理其网站。

I need to provide a few forms (Contact, Event registration/payment and Donation payment). 我需要提供一些表格(联系方式,活动注册/付款和捐赠付款)。 These forms also require that certain aspects of the forms can be updated via the front-end leveraging K2. 这些表格还要求可以通过前端杠杆K2更新表格的某些方面。 (eg. The email address to send form submissions to.) With most forms components this can be done easily from the admin panel, however this is too complicated for non-techy customers and means we would have to provide admin access instead of just front-end. (例如,用于将表单提交发送到的电子邮件地址。)对于大多数表单组件,可以从管理面板轻松完成此操作,但是对于非技术类客户而言,这太复杂了,这意味着我们将不得不提供管理员访问权限,而不仅仅是前端-结束。 Not a good solution. 不是一个好的解决方案。

I have created a K2 contact Form plugin that will allow a customer to update where the email is sent on submission, when logged into the front-end with correct permissions. 我创建了一个K2联系人表单插件,当使用正确的权限登录到前端时,该插件将允许客户更新提交时发送电子邮件的位置。 So far so good. 到现在为止还挺好。 I chose a plugin to accomplish this so we could leverage the existing front-end editing. 我选择了一个插件来完成此操作,以便我们可以利用现有的前端编辑。

The issue I ran into is how to make my plugin create a table, preferably on install, as well as save form data to that table on successful submission. 我遇到的问题是如何使我的插件创建一个表,最好是在安装时创建一个表,以及如何在成功提交后将表单数据保存到该表中。 I'm not sure that this is possible using a plugin and have not found any documentation or sources mentioning how to accomplish this task. 我不确定是否可以使用插件来实现,还没有找到任何文档或资料来源提及如何完成此任务。

I was hoping someone may be able to confirm either way if this is possible? 我希望有人能够确认这两种方式是否可行? Any suggestions, comments, etc would be greatly appreciated. 任何建议,意见等,将不胜感激。

While installing plugin you can create DB tables, Its not a big deal create the SQL file with proper table query and set that inside your XML file. 在安装插件时,您可以创建DB表,用适当的表查询创建SQL文件并将其设置在XML文件中没什么大不了的。

Also you can create a forms(with many fields) inside your plugin file, But the problem is you should have any components controller and model related to this form submission task. 您也可以在插件文件中创建一个表单(包含许多字段),但是问题是您应该具有与此表单提交任务相关的任何组件控制器和模型。 Bcoz form submission you cannot handle inside plugin file, it should required a controller and model files. 无法在插件文件中处理的Bcoz表单提交,它需要一个controllermodel文件。

So basically your plugin have related components then you can achieve it with form action like below. 因此,基本上您的插件具有相关的组件,然后您可以通过如下所示的表单操作来实现它。

<form action="index.php?option=com_yourcomponent&task=your_controller.your_function">

For creating DB table while installing plugin check this link 要在安装插件时创建数据库表,请检查此链接

Hope its helps.. 希望能有所帮助

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

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