diff --git a/framework/elements/formbuilder/ajax.php b/framework/elements/formbuilder/ajax.php
index 94d39f26..c248e5b8 100644
--- a/framework/elements/formbuilder/ajax.php
+++ b/framework/elements/formbuilder/ajax.php
@@ -20,17 +20,20 @@
use Astroid\Helper;
$mainframe = Factory::getApplication();
-$asformbuilder = $mainframe->input->get('as-form-builder-', array(), 'RAW');
-$unqid = $mainframe->input->get('form_id', '', 'ALNUM');
-$element = Helper::getElement($unqid);
+$asformbuilder = $mainframe->input->post->get('as-form-builder-', array(), 'RAW');
+$unqid = $mainframe->input->post->get('form_id', '', 'string');
+$source = $mainframe->input->post->get('source', '', 'string');
+$template = $mainframe->input->post->get('template', '', 'string');
+$layout_type = $mainframe->input->post->get('layout_type', '', 'string');
+$element = Helper::getElement($unqid, '', ['source' => $source, 'template' => $template, 'layout_type' => $layout_type]);
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$return = array();
try {
- if (!empty($asformbuilder)) {
+ if (empty($asformbuilder)) {
throw new \Exception(Text::_('ASTROID_AJAX_ERROR_INVALID_FORM_DATA'));
}
- if (!empty($element)) {
+ if (empty($element)) {
throw new \Exception(Text::_('ASTROID_AJAX_ERROR_INVALID_FORM_ID'));
}
$params = $element['params'];
diff --git a/framework/elements/formbuilder/formbuilder.php b/framework/elements/formbuilder/formbuilder.php
index 73f09d30..c0ba4ee6 100644
--- a/framework/elements/formbuilder/formbuilder.php
+++ b/framework/elements/formbuilder/formbuilder.php
@@ -33,7 +33,6 @@
if (empty($form_elements) || !count($form_elements)) {
return false;
}
-
$row_column_cls = '';
$responsive_key = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs'];
foreach ($responsive_key as $key) {
@@ -158,6 +157,15 @@
echo '';
echo '';
echo '';
+if (isset($options['source']) && $options['source']) {
+ echo '';
+}
+if (isset($options['template']) && $options['template']) {
+ echo '';
+}
+if (isset($options['layout_type']) && $options['layout_type']) {
+ echo '';
+}
echo '';
$button_style = $params->get('button_style', 'primary');
diff --git a/framework/library/astroid/Element/Layout.php b/framework/library/astroid/Element/Layout.php
index 5c40070e..f138388f 100644
--- a/framework/library/astroid/Element/Layout.php
+++ b/framework/library/astroid/Element/Layout.php
@@ -54,7 +54,9 @@ public static function renderSublayout($source, $template = '', $type = 'layouts
'title'=> 'title'
]
];
- $options['layout_type'] = 'sublayout';
+ $options['layout_type'] = $type;
+ $options['source'] = $source;
+ $options['template'] = !empty($template) ? $template : Framework::getTemplate()->template;
$content = '';
foreach ($layout['sections'] as $section) {
$section = new Section($section, $devices, $options);
diff --git a/framework/library/astroid/Element/Section.php b/framework/library/astroid/Element/Section.php
index 6856cdca..388e3fb3 100644
--- a/framework/library/astroid/Element/Section.php
+++ b/framework/library/astroid/Element/Section.php
@@ -22,7 +22,7 @@ class Section extends BaseElement
public function __construct($data, $devices, $options = array())
{
- if (isset($options['layout_type']) && $options['layout_type'] == 'sublayout') {
+ if (isset($options['layout_type']) && ($options['layout_type'] == 'layouts' || $options['layout_type'] == 'article_layouts')) {
$this->_tag = 'div';
}
parent::__construct($data, $devices, $options);
diff --git a/framework/library/astroid/Helper.php b/framework/library/astroid/Helper.php
index 29e58751..c6dc5a1c 100644
--- a/framework/library/astroid/Helper.php
+++ b/framework/library/astroid/Helper.php
@@ -8,6 +8,7 @@
*/
namespace Astroid;
+use Astroid\Element\Layout;
use Joomla\CMS\Cache\CacheControllerFactoryInterface;
use Joomla\CMS\Event\Cache\AfterPurgeEvent;
use Joomla\CMS\Factory;
@@ -402,11 +403,20 @@ public static function getAllAstroidElements($mode = '', $template_id = null)
return $return;
}
- public static function getElement($unqid, $template = null) {
+ public static function getElement($unqid, $template = null, $options = []) {
if (empty($template)) {
$template = Framework::getTemplate();
}
- $layout = $template->getLayout();
+ if (isset($options['source']) && !empty($options['source'])) {
+ $sublayout = Layout::getDataLayout($options['source'], (isset($options['template']) && !empty($options['template']) ? $options['template'] : ''), (isset($options['layout_type']) && !empty($options['layout_type']) ? $options['layout_type'] : 'layouts'));
+ if (!isset($sublayout['data']) || !$sublayout['data']) {
+ return false;
+ }
+ $layout = \json_decode($sublayout['data'], true);
+ } else {
+ $layout = $template->getLayout();
+ }
+
foreach ($layout['sections'] as $section) {
if ($section['id'] == $unqid) {
$section['params'] = self::loadParams($section['params']);