Added option to dynamicly set the sub-form layout from global options. Fixed bug in compiler that caused index warning.

This commit is contained in:
2020-07-13 04:52:06 +02:00
parent 25afc31e7f
commit 3a5681ce43
21 changed files with 219 additions and 30 deletions

View File

@ -5861,6 +5861,47 @@ abstract class ComponentbuilderHelper
return $d && $d->format($format) == $date;
}
/**
* The subform layouts
**/
protected static $subformLayouts = false;
/**
* get the subform layout
*
* @input string The view name
* @input string The string name
*
* @returns string on success
**/
public static function getSubformLayout($view, $field, $default = 'repeatablejcb')
{
// get global values
if (self::$subformLayouts === false)
{
self::$subformLayouts = JComponentHelper::getParams('com_componentbuilder')->get('subform_layouts', false);
}
// check what we found (else) return default
if (self::checkObject(self::$subformLayouts))
{
// looking for
$target = $view . '.' . $field;
foreach (self::$subformLayouts as $subform)
{
if ($target === $subform->view_field)
{
return $subform->layout;
}
elseif ('default' === $subform->view_field)
{
$default = $subform->layout;
}
}
}
return $default;
}
/**
* Load the Composer Vendors