mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Manage onCreate now looks to the deferredBinding property
This commit is contained in:
parent
3cff8caa15
commit
032d8aafce
@ -220,7 +220,7 @@ class RelationController extends ControllerBehavior
|
||||
$this->relationModel = $this->relationObject->getRelated();
|
||||
|
||||
$this->readOnly = $this->getConfig('readOnly');
|
||||
$this->deferredBinding = $this->getConfig('deferredBinding');
|
||||
$this->deferredBinding = $this->getConfig('deferredBinding') || !$this->model->exists;
|
||||
$this->toolbarButtons = $this->evalToolbarButtons();
|
||||
$this->viewMode = $this->viewMode ?: $this->evalViewMode();
|
||||
$this->manageMode = $this->manageMode ?: $this->evalManageMode();
|
||||
@ -599,11 +599,13 @@ class RelationController extends ControllerBehavior
|
||||
$saveData = $this->manageWidget->getSaveData();
|
||||
|
||||
if ($this->viewMode == 'multi') {
|
||||
$sessionKey = $this->deferredBinding ? $this->relationGetSessionKey(true) : null;
|
||||
|
||||
if ($this->relationType == 'hasMany') {
|
||||
$newModel = $this->relationObject->create($saveData, $this->relationGetSessionKey(true));
|
||||
$newModel = $this->relationObject->create($saveData, $sessionKey);
|
||||
}
|
||||
elseif ($this->relationType == 'belongsToMany') {
|
||||
$newModel = $this->relationObject->create($saveData, [], $this->relationGetSessionKey(true));
|
||||
$newModel = $this->relationObject->create($saveData, [], $sessionKey);
|
||||
}
|
||||
|
||||
$newModel->commitDeferred($this->manageWidget->getSessionKey());
|
||||
@ -711,14 +713,11 @@ class RelationController extends ControllerBehavior
|
||||
$models = $this->relationModel->whereIn($foreignKeyName, $checkedIds)->get();
|
||||
foreach ($models as $model) {
|
||||
|
||||
$useDefer = $this->deferredBinding || !$this->model->exists;
|
||||
if ($useDefer) {
|
||||
$this->relationObject->add($model, $this->relationGetSessionKey());
|
||||
}
|
||||
else {
|
||||
$this->relationObject->add($model);
|
||||
}
|
||||
$sessionKey = $this->deferredBinding
|
||||
? $this->relationGetSessionKey()
|
||||
: null;
|
||||
|
||||
$this->relationObject->add($model, $sessionKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user