I created a system plugin with the onContentPrepareForm()
method to load an entire module options form, and the form loads correctly, but will not save the entered data.
The coding
/plugins/system/dropmods/dropmods.php
public function onContentPrepareForm($form, $data)
{
if( $form->getName() == 'com_modules.module' && $data->module == 'mod_stuff' ) {
JForm::addFormPath(__DIR__.'/mods/');
$form->loadFile('mod_stuff', false);
}
}
The override form mod_stuff.xml
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="params">
<fieldset name="basic">
<field type="textarea" name="thetextarea" label="Write Stuff" />
<field type="text" name="thetext" label="Just Write" />
</fieldset>
</fields>
</form>
The module's manifest XML mod_stuff.xml
modules/mod_stuff
The manifest just serves as an item to register the module but all files are sourced from the plugin. The installation process of the plugin creates the module folder and registers to the DB _extensions
table
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.1" client="site" method="upgrade">
<name>mod_stuff</name>
<author>The author</author>
<creationDate>July</creationDate>
<copyright>Copyright here</copyright>
<license>GNU General Public License stuff</license>
<authorEmail></authorEmail>
<authorUrl></authorUrl>
<version>1.0</version>
<description>the detail</description>
</extension>
mod_stuff.php
modules/mod_stuff
<?php defined('_JEXEC') or exit('stuff');
include JPATH_PLUGINS.'/system/dropmods/mods/mod_stuff.php';
What has worked
If I use a subform method in the module's manifest file modules/mod_stuff/mod_stuff.xml
to load the override file, the data saves correctly, however the subform process create additional parent object name settings
and it poses a bit of challenge.
<config>
<fields name="params">
<fieldset name="basic">
<field
type="subform"
name="settings"
formsource="plugins/system/dropmods/mods/mod_stuff.xml"
hiddenLabel="true"
/>
</fieldset>
</fields>
</config>
What's required to allow the plugin override form to save the data?