Skip to content
33 changes: 17 additions & 16 deletions administrator/components/com_fields/src/Model/GroupModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,29 +240,30 @@ protected function preprocessForm(Form $form, $data, $group = 'content')

$parts = FieldsHelper::extract($this->state->get('filter.context'));

// If we don't have a valid context then return early
if (!$parts) {
return;
}

// Extract the component name
$component = $parts[0];

// Extract the optional section name
$section = (count($parts) > 1) ? $parts[1] : null;
// Extract the section name
$section = $parts[1];

if ($parts) {
// Set the access control rules field component value.
$form->setFieldAttribute('rules', 'component', $component);
}
// Set the access control rules field component value.
$form->setFieldAttribute('rules', 'component', $component);

if ($section !== null) {
// Looking first in the component models/forms folder
$path = Path::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/models/forms/fieldgroup/' . $section . '.xml');
// Looking first in the component models/forms folder
$path = Path::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/models/forms/fieldgroup/' . $section . '.xml');

if (file_exists($path)) {
$lang = Factory::getLanguage();
$lang->load($component, JPATH_BASE);
$lang->load($component, JPATH_BASE . '/components/' . $component);
if (file_exists($path)) {
$lang = Factory::getLanguage();
$lang->load($component, JPATH_BASE);
$lang->load($component, JPATH_BASE . '/components/' . $component);

if (!$form->loadFile($path, false)) {
throw new \Exception(Text::_('JERROR_LOADFILE_FAILED'));
}
if (!$form->loadFile($path, false)) {
throw new \Exception(Text::_('JERROR_LOADFILE_FAILED'));
}
}
}
Expand Down