如何设置动作以在joomla模块中形成 [英] how to set action to form in joomla modules

查看:59
本文介绍了如何设置动作以在joomla模块中形成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我模块中的文件结构

this is my file structure in my modules

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

我在default.php文件中有此表格

i have this form in default.php file

<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文件后通过它 表单中的action属性必须设置为??

i want to pass it after click on submit to heper.php file in that form action attribute must set to what ??

推荐答案

您无需设置操作,只需为其命名即可.这样您的表单将如下所示:

You don't need to set an action, you can simply give it a name. So you form would look something like this:

<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中调用该函数):

Then your mod_helloworld.php (which calls the function in the helper.php):

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

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

请注意,您当然必须进行一些更改以满足自己的需要,因为上面的代码就在这里,这为您提供了一个小小的开端

Please note that you will of course have to make a few changes to suits your needs as the code above is just there to give you a small head start

这篇关于如何设置动作以在joomla模块中形成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆