Merge pull request #940 from Flynsarmy/customRelationContext
Support passing custom contexts to relationcontroller
This commit is contained in:
commit
8d0d46ffc7
|
|
@ -506,7 +506,7 @@ class RelationController extends ControllerBehavior
|
|||
|
||||
return $results->lists($foreignKeyName);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
|
|
@ -1027,10 +1027,12 @@ class RelationController extends ControllerBehavior
|
|||
* Form
|
||||
*/
|
||||
elseif ($this->manageMode == 'form' && isset($this->config->form)) {
|
||||
$context = !empty($this->config->manage['context']) ? $this->config->manage['context'] : 'relation';
|
||||
|
||||
$config = $this->makeConfig($this->config->form);
|
||||
$config->model = $this->relationModel;
|
||||
$config->arrayName = class_basename($this->relationModel);
|
||||
$config->context = 'relation';
|
||||
$config->context = is_string($context) ? $context : 'relation';
|
||||
$config->alias = $this->alias . 'ManageForm';
|
||||
|
||||
/*
|
||||
|
|
@ -1043,6 +1045,17 @@ 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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue