Tidy up code from #940

This commit is contained in:
Samuel Georges 2015-02-19 19:38:50 +11:00
parent 8d0d46ffc7
commit c7881ff2dc
1 changed files with 12 additions and 13 deletions

View File

@ -1027,12 +1027,22 @@ class RelationController extends ControllerBehavior
* Form
*/
elseif ($this->manageMode == 'form' && isset($this->config->form)) {
$context = !empty($this->config->manage['context']) ? $this->config->manage['context'] : 'relation';
/*
* Determine supplied form context
*/
if ($context = array_get($this->config->manage, 'context')) {
if (is_array($context)) {
$context = $this->manageId
? array_get($context, 'update')
: array_get($context, 'create');
}
}
$config = $this->makeConfig($this->config->form);
$config->model = $this->relationModel;
$config->arrayName = class_basename($this->relationModel);
$config->context = is_string($context) ? $context : 'relation';
$config->context = $context ?: 'relation';
$config->alias = $this->alias . 'ManageForm';
/*
@ -1045,17 +1055,6 @@ class RelationController extends ControllerBehavior
'class' => get_class($config->model), 'id' => $this->manageId
]));
}
else {
if (is_array($context) && isset($context['update'])) {
$config->context = $context['update'];
}
}
}
else {
if (is_array($context) && isset($context['create'])) {
$config->context = $context['create'];
}
}
$widget = $this->makeWidget('Backend\Widgets\Form', $config);