更新时间:2023-11-13 15:34:04
是的,您应该在模块帮助程序类中进行表单处理.将任何逻辑排除在模板文件之外,您可以使用mod_mymodule.php
调用帮助程序方法并在包含视图文件之前分配变量.
Yes, you should do form processing in module helper class. Keep any logic out of the template file, and you can use mod_mymodule.php
to call helper methods and assign variables before including the view file.
请勿设置为表单动作帮助文件!我认为在您的情况下,操作应该在同一页面上,因此您也可以省略操作网址.
Do not set as form action helper file! I think in your case action should be the same page, so you can also ommit action url.
根据评论的要求,这就是您的mod_mymodule.php
As requested in the comments, this would be the content of your mod_mymodule.php
// include helper file
require_once dirname(__FILE__).'/helper.php';
// call some method of the helper class
$items = modMymoduleHelper::getItems();
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
// render view file from mod_mymodule/tmpl/default.php, $items is available in the view file
require JModuleHelper::getLayoutPath('mod_mymodule', $params->get('layout', 'default'));