大家好我正在开发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>
答案 0 :(得分:2)
您需要将以下代码添加到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>