Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
578 changes: 561 additions & 17 deletions modules/backend/behaviors/RelationController.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class="btn btn-sm btn-secondary wn-icon-trash-o"
data-request="onRelationButtonDelete"
data-request-confirm="<?= e(trans('backend::lang.relation.delete_confirm')) ?>"
data-request-success="$.wn.relationBehavior.changed('<?= e($relationField) ?>', 'deleted')"
data-request-success="$.wn.relationBehavior.changed('<?= e($relationFieldName) ?>', 'deleted')"
data-stripe-load-indicator>
<?= e(trans($text)) ?>
</button>
Expand All @@ -16,7 +16,7 @@ class="btn btn-sm btn-secondary wn-icon-trash-o"
disabled="disabled"
data-request="onRelationButtonDelete"
data-request-confirm="<?= e(trans('backend::lang.relation.delete_confirm')) ?>"
data-request-success="$.wn.relationBehavior.changed('<?= e($relationField) ?>', 'deleted')"
data-request-success="$.wn.relationBehavior.changed('<?= e($relationFieldName) ?>', 'deleted')"
data-trigger-action="enable"
data-trigger="#<?= $this->relationGetId('view') ?> .control-list input[type=checkbox]"
data-trigger-condition="checked"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<button
class="btn btn-sm btn-secondary wn-icon-minus"
data-request="onRelationButtonRemove"
data-request-success="$.wn.relationBehavior.changed('<?= e($relationField) ?>', 'removed')"
data-request-success="$.wn.relationBehavior.changed('<?= e($relationFieldName) ?>', 'removed')"
data-stripe-load-indicator>
<?= e(trans($text)) ?>
</button>
Expand All @@ -14,7 +14,7 @@ class="btn btn-sm btn-secondary wn-icon-minus"
})"
disabled="disabled"
data-request="onRelationButtonRemove"
data-request-success="$.wn.relationBehavior.changed('<?= e($relationField) ?>', 'removed')"
data-request-success="$.wn.relationBehavior.changed('<?= e($relationFieldName) ?>', 'removed')"
data-trigger-action="enable"
data-trigger="#<?= $this->relationGetId('view') ?> .control-list input[type=checkbox]"
data-trigger-condition="checked"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
href="javascript:;"
class="btn btn-sm btn-secondary wn-icon-unlink"
data-request="onRelationButtonUnlink"
data-request-success="$.wn.relationBehavior.changed('<?= e($relationField) ?>', 'removed')"
data-request-success="$.wn.relationBehavior.changed('<?= e($relationFieldName) ?>', 'removed')"
data-request-confirm="<?= e(trans('backend::lang.relation.unlink_confirm')) ?>"
data-stripe-load-indicator>
<?= e(trans($text)) ?>
Expand Down
14 changes: 14 additions & 0 deletions modules/backend/formwidgets/RelationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ public function render()

$relation = $this->relation ?: $this->formField->fieldName;

// Explicitly binds the controller's relation context to THIS
// widget's own model/field pair before rendering. Needed for a
// nested relation manager (one rendered inside another relation
// manager's own manage form): without this, relationRender()'s
// own internal validateField() check would lazily call
// initRelation() using $this->model - RelationController's own,
// currently-active model, which for a nested field is still
// whatever the OUTER field left it as, not this widget's own
// bound model. Harmless and idempotent for a root-level field
// (the widget's model and the controller's current model are
// already the same one), so this applies at any depth
// uniformly, with no special-casing needed here.
$this->controller->initRelation($this->model, $relation);

return $this->controller->relationRender($relation, $options);
}

Expand Down
Loading
Loading