javascript - Joomla 自定义表单字段类型

标签 javascript html joomla joomla2.5 joomla-extensions

大家好,我正在 Joomla 2.5/3 中开发自定义表单字段类型。但我的代码不起作用,我的意思是当我按下它时,它不会显示消息,而且它有一个不同的 ID。这是我的代码:

{module}/elements/testfield.php

<?php

/**
 * @copyright   Copyright (C) 2011 Cedric KEIFLIN alias ced1870
 * http://www.joomlack.fr
 * @license     GNU/GPL
 * */
// no direct access
defined('_JEXEC') or die('Restricted access');

class JFormFieldTestfield extends JFormField {

    protected $type = 'testfield';

    protected function getInput() {
        $document = JFactory::getDocument();
        $html = '<input name="' . $this->name . '" id="xxxfffaaa" value="' . $this->value . '" onclick="" />';
        return $html;
    }

    protected function getLabel() {
    }

}

*

{module}/{module_name}.xml

...     
<fields name="params">
            <fieldset name="basic">

                ....
                <field name="blablaname" type="testfield" label="this is label"/>

            </fieldset>
        </fields>

最佳答案

您需要将以下代码添加到fields标签

addfieldpath="modules/mod_mymodule/elements"

所以你的代码将如下所示:

<fields name="params" addfieldpath="modules/mod_mymodule/elements">
    <fieldset name="basic">
        <field name="blablaname" type="testfield" label="this is label"/>
    </fieldset>
</fields>

关于javascript - Joomla 自定义表单字段类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14564348/

相关文章:

javascript - 自定义函数无法在背景网格 :exitEditMode 上触发

没有时间的Javascript日期方法

javascript - 将多个文件转换为 HTML(来自 Markdown)?

html - 在圆形按钮上居中文本

mysql - Joomla - "Unknown column ' 援助'在 'order clause'

joomla - 如何从 joomla 1.6 中的文章 ID 获取菜单项的 url?

javascript - jQuery preventDefault 不表现

javascript - ReactJs 错误 - 警告 : setState(. ..):只能更新已安装或安装的组件

html - 为什么溢出滚动在移动 webkit 中的 html 标签上不起作用?

php - Joomla 获取插件 ID