I have currently created a Joomla Module, and i would like to make it a bit more advanced now. I have created a Custom field, and i have tried to add it to the mod_NAMEOFMODULE.xml file. To use it when configuring the module. Here is the code for the custom field: `
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
class UserFieldList extends JFormFieldList { protected $type = 'UserInfo';
public function getOptions() {
$cities = array(
array('value' => 1, 'text' => 'New York'),
array('value' => 2, 'text' => 'Chicago'),
array('value' => 3, 'text' => 'San Francisco'),
);
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $cities);
// pre-select values 2 and 3 by setting the protected $value property
$this->value = array(2, 3);
return $options;
}
}` It is from the tutorial by joomla: https://docs.joomla.org/Creating_a_custom_form_field_type#Location_of_files
The .xml file code here: <?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.1.0" client="site" method="upgrade">
<name>Hello, World!</name>
<author>John Doe</author>
<version>1.0.0</version>
<description>A simple Hello, World! module.</description>
<files>
<filename>mod_helloworld.xml</filename>
<filename module="mod_helloworld">mod_helloworld.php</filename>
<filename>index.html</filename>
<filename>helper.php</filename>
<filename>tmpl/default.php</filename>
<filename>tmpl/index.html</filename>
<filename>UserFieldList.php</filename>
<folder>tmpl</folder>
</files>
<config>
<fields name="params">
<fieldset name="basic" addfilepath="/UserFieldList.php">
<field name="userlist" type="UserInfo" label="userlist">
<option>YNO</option>
</field>
</fieldset>
</fields>
</config>
</extension>
. This is taken from the module tutorial by joomla: https://docs.joomla.org/J3.x:Creating_a_simple_module.
As it can be seen in the .xml file, i have been trying to add the filepath in as seen in the custom field tutorial as well as providing the correct type under . The problem is, when i install the module, it only displays a textfield, with the correct name "userlist". It is my understanding, that the custom field is not recognised. Since the textfield is displayed, but not the desired dropdown with 3 options as seen from the UserFieldList class. So is there a way to implement a customfield inside the modules .xml file? Thank you in advance :)