Skip to content

Commit

Permalink
Loading chrome specific form files from chrome folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Hunziker committed Nov 7, 2020
1 parent 59319ff commit 9ccd295
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions administrator/components/com_modules/src/Model/ModuleModel.php
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Helper\ModuleHelper;
Expand All @@ -23,6 +24,7 @@
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Table\Table;
use Joomla\Component\Modules\Administrator\Helper\ModulesHelper;
use Joomla\Database\ParameterType;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
Expand Down Expand Up @@ -899,6 +901,39 @@ protected function preprocessForm(Form $form, $data, $group = 'content')
Form::addFormPath(JPATH_ADMINISTRATOR . '/components/com_modules/models/forms');
$form->loadFile('advanced', false);

// Load chrome specific params for global files
$chromePath = JPATH_SITE . '/layouts/chromes';
$chromeFormFiles = Folder::files($chromePath, '.*\.xml');

if ($chromeFormFiles)
{
\JForm::addFormPath($chromePath);

foreach ($chromeFormFiles as $formFile)
{
$form->loadFile(basename($formFile, '.xml'), false);
}
}

// Load chrome specific params for template files
$templates = ModulesHelper::getTemplates($clientId);

foreach ($templates as $template)
{
$chromePath = $client->path . '/templates/' . $template->element . '/html/layouts/chromes';
$chromeFormFiles = Folder::files($chromePath, '.*\.xml');

if ($chromeFormFiles)
{
\JForm::addFormPath($chromePath);

foreach ($chromeFormFiles as $formFile)
{
$form->loadFile(basename($formFile, '.xml'), false);
}
}
}

// Trigger the default form events.
parent::preprocessForm($form, $data, $group);
}
Expand Down

0 comments on commit 9ccd295

Please sign in to comment.