2

Hi guys I am developing custom form field type in Joomla 2.5/3 . But my code doesn't work, I mean when I press on it, it doesn't show message and also it has a different ID. here my code:

{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>
Irakli
  • 1,151
  • 5
  • 30
  • 55

1 Answers1

2

You need to add the following code to the fields tag

addfieldpath="modules/mod_mymodule/elements"

so your code will look like this:

<fields name="params" addfieldpath="modules/mod_mymodule/elements">
    <fieldset name="basic">
        <field name="blablaname" type="testfield" label="this is label"/>
    </fieldset>
</fields>
Lodder
  • 19,758
  • 10
  • 59
  • 100