In my system plugin , I am using following to load default options xml file for templates
function onContentPrepareForm($form, $data) {
if (!($form instanceof JForm)){
$this->_subject->setError('JERROR_NOT_A_FORM');
}
// Template defaults
if ($form->getName() == 'com_templates.style') {
JForm::addFormPath('pathtofolder');
$form->loadFile('xmlfile', false, false , true);
}
}
works fine
now in templateDetails.xml by default I will have params fields group empty
...
<config>
<fields name="params">
</fields>
</config>
...
also works fine and it display the default params from my xml file.
Now I want to give users an option to override the existing default param by simply adding it inside the templateDetails.xml.
example protostar default I changed templateBackgroundColor value from F4F6F7 to FF6600
<config>
<fields name="params">
<fieldset name="advanced">
<field name="templateBackgroundColor" class="" type="color" default="#FF6600"
label="TPL_PROTOSTAR_BACKGROUND_COLOR_LABEL"
description="TPL_PROTOSTAR_BACKGROUND_COLOR_DESC" />
</fieldset>
</fields>
</config>
this also works , but the field is in wrong position now it is located as the first field on top and it was second.
According to the loadFile() and load() method it should override the field in its exact place.
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/form/form.php#L851 https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/form/form.php#L727
What am I missing here? Did the load fire to soon before the template xml ?
Any help is appreciated.