public function getWidget($ctrl, \jelix\forms\HtmlWidget\ParentWidgetInterface $parentWidget = null)
{
if (isset($this->widgets[$ctrl->ref])) {
return $this->widgets[$ctrl->ref];
}
$config = \jApp::config()->{$this->formConfig};
if (isset($this->pluginsConf[$ctrl->ref])) {
//first the builder conf
$pluginName = $this->pluginsConf[$ctrl->ref];
} elseif (isset($config[$ctrl->type])) {
//then the ini conf
$pluginName = $config[$ctrl->type];
} else {
//finaly the control type
$pluginName = $ctrl->type . '_' . $this->formType;
}
$className = $pluginName . 'FormWidget';
$plugin = \jApp::loadPlugin($pluginName, 'formwidget', '.formwidget.php', $className, array($ctrl, $this, $parentWidget));
if (!$plugin) {
throw new \Exception('Widget ' . $pluginName . ' not found');
}
$this->widgets[$ctrl->ref] = $plugin;
return $plugin;
}