0

作为一个对 Joomla 很陌生的 PHP 开发人员,我一直在兜圈子,试图在网页上创建表单。我找不到可以轻松记录这些步骤的合适来源。但经过大量搜索,我发现了这个:http ://www.ostraining.com/blog/how-tos/development/getting-started-with-jform/

但我不知道这些文件在我的主机上的什么位置。

有人可以概述一下这些步骤吗?我不是在寻找完整的代码。就像:

  1. 第一步创建html表单
  2. 使用键值创建 xml 文件,例如...
  3. ...

包含文本框和日期字段的示例将是极好的。

基本上我想发布内容并使用 php 打印出来。

再一次,我只需要步骤。不是完整的代码。请不要使用第 3 方模块/插件。

谢谢!

更多信息...看来我的问题太宽泛了。让我们来看一个案例。这就是我想做的。

在网页上,当单击菜单链接时,用户会看到一个表单。表格上有姓名和出生日期。输入后,表单提交。网页必须打印出类似“Hello X, your age is Y”的输出。X 是姓名,Y 是计算的年龄。

我确实知道如何使用标准 PHP。至于我对 Joomla 的专业知识水平,我查看了文档并使用一些非常简单的模块创建了自己的模板。如果我要打破任何规则,我可以轻松地将表单以“老式方式”插入 index.php 中。但我知道这在 Joomla 世界中是错误的。我还考虑过将表格作为文章插入。但我看到 UI 组件存在限制。例如,我可能必须使用一些额外的元素(如 JQuery)来获取日期输入框。

这就是为什么我只想以 Joomla 方式创建它,而不依赖于任何第三方组件/插件。

4

1 回答 1

0

It sounds to me like you may be having trouble understanding how to add php, not just how to add a form. The Joomla UI is a UI for end users it's not one for developers. For adding a form you need to have a way to get the form into the UI. That's why people have probably recommended that you use a forms extension, because those provide a simple UI for doing so.

How you make the form is going to depend on what you are doing with it and whether you want to save to the database i.e. is it a search form, a filter in the back end UI, or creating content that you want to save.

Do you want to insert this form inside an article? Or do you want it to be its own separate thing that would have a menu item?

So, for any kind of proper Joomla code you need to make an extension, and in your case I would guess it is probably appropriate to make a plugin. You can use the profile plugin as a model if you want.

In your plugin the way I usually would do it (after doing the usual content plugin work of identifying the event and context and so on) would be to define my fields and fieldsets in an xml file.

Then in your php you would instantiate a JForm and echo out the labels and values the way it is done in all the core forms (i.e. look at the article edit layouts).

Without knowing more about the context and purpose of your form it's hard to give more detailed advice than that. I don't want to put links to docs that are going to just be frustrating for you.

于 2013-05-03T08:28:01.903 回答