joomla - 如何在 joomla 模块中设置表单的操作

标签 joomla

这是我模块中的文件结构

tmpl
    default.php
helper.php
mod_helloword.php
mod_helloword.xml

我在default.php文件中有这个表单

<form action="" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>

我想在点击提交到heper.php文件后传递它 在该表单中,操作属性必须设置为什么?

最佳答案

您无需设置操作,只需为其指定名称即可。所以你的表单看起来像这样:

<form name="submit" method="post" enctype="multipart/form-data">
  <label for="file">Filename:</label>
  <input type="file" name="file" id="file"><br>
  <input type="submit" name="submit" value="Submit">
</form>

然后是你的helper.php:

class ModHelloWorldHelper {
    public static function submit($file) {
        // some code goes here
    }
}

然后你的mod_helloworld.php(调用helper.php中的函数):

$input = new JInput;
$post = $input->getArray($_POST);

if ($post["submit"]) {
    modHelloWorldHelper::submit($file);
}

请注意,您当然需要进行一些更改以满足您的需求,因为上面的代码只是为了给您一个小小的开始

关于joomla - 如何在 joomla 模块中设置表单的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20659236/

相关文章:

css - 使用 joomla 3.2 设计子菜单项

Joomla 字段 : change dynamically the readonly property

php - echo jQuery 函数中的 php 变量

php - 如何添加 jReject - jQuery 浏览器拒绝到 Joomla 1.5 网站

php - 尝试将 Joomla 网站移至新帐户时出现 SQL 错误

joomla - 在周末学习 Joomla

php - 如何更新 joomla 模块或后端中的表?

php - MYSQL 的 MAX MIN 日期范围

php - 通过 JavaScript 与 PHP 获取服务器路径

c# - 类似于 Joomla/Mambo/Drupal 的 c# 操作系统项目有哪些替代方案?