diff --git a/framework/fields/astroidlayoutdata.php b/framework/fields/astroidlayoutdata.php index 8621c8b1..b2e6c6ed 100644 --- a/framework/fields/astroidlayoutdata.php +++ b/framework/fields/astroidlayoutdata.php @@ -92,6 +92,14 @@ protected function getInput() { foreach ($row['cols'] as $col) { foreach ($col['elements'] as $element) { if (isset($form_template[$element['type']]) && $form_template[$element['type']]['info']['element_type'] == 'widget') { + $availableForm = Helper\AstroidForm::getAvailableFormArray($form_template[$element['type']]['content']); + $availableElements = []; + foreach ($element['params'] as $availableElement) { + if (isset($availableForm[$availableElement['name']])) { + $availableElements[] = $availableElement; + } + } + $element['params'] = $availableElements; $article_data = Path::clean(JPATH_SITE . '/media/templates/site/' . $article_layout->template . '/astroid/article_widget_data/'. $id . '_' . $element['id'] . '.json'); if (file_exists($article_data)) { $widget_data = file_get_contents($article_data); diff --git a/framework/library/astroid/Helper/AstroidForm.php b/framework/library/astroid/Helper/AstroidForm.php index a86b7990..5c20db5b 100644 --- a/framework/library/astroid/Helper/AstroidForm.php +++ b/framework/library/astroid/Helper/AstroidForm.php @@ -73,4 +73,19 @@ public function getForm() { return $this->form; } + + public static function getAvailableFormArray($fieldsets = []): array + { + $arr = []; + foreach ($fieldsets as $fieldset) { + foreach ($fieldset->childs as $group) { + foreach ($group['fields'] as $field) { + if (isset($field['name']) && !empty($field['name'])) { + $arr[$field['name']] = true; + } + } + } + } + return $arr; + } }