Navigation Menu

Skip to content

Commit

Permalink
Fix for config loader in FormHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
Denys Kyselov committed Nov 14, 2014
1 parent 1b786b0 commit b0b851f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/View/Helper/FormHelper.php
Expand Up @@ -202,7 +202,8 @@ public function __construct(View $View, array $config = []) {
unset($config['registry']);
}
if (isset($config['widgets'])) {
$widgets = $config['widgets'] + $widgets;
if (is_string($config['widgets'])) $config['widgets'] = [$config['widgets']];
$widgets = $widgets + $config['widgets'];
unset($config['widgets']);
}

Expand Down
8 changes: 3 additions & 5 deletions src/View/Widget/WidgetRegistry.php
Expand Up @@ -62,11 +62,7 @@ class WidgetRegistry {
public function __construct(StringTemplate $templates, View $view, $widgets = []) {
$this->_templates = $templates;
if (!empty($widgets)) {
if (is_string($widgets)) {
$this->load($widgets);
} else {
$this->add($widgets);
}
$this->add($widgets);
}
$this->_widgets['_view'] = $view;
}
Expand Down Expand Up @@ -115,6 +111,8 @@ public function add(array $widgets) {
throw new \RuntimeException(
'Widget objects must implement Cake\View\Widget\WidgetInterface.'
);
} elseif (is_string($object)){
$this->load($object);
}
}
$this->_widgets = $widgets + $this->_widgets;
Expand Down

0 comments on commit b0b851f

Please sign in to comment.