Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add extension events for the main relation widgets #1129

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add events docblocks
mjauvin committed May 17, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 192f01ff1b42f3231998b3ed04640479b1943f97
41 changes: 41 additions & 0 deletions modules/backend/behaviors/RelationController.php
Original file line number Diff line number Diff line change
@@ -394,6 +394,19 @@ public function initRelation($model, $field = null)

/*
* View widget
*
* @event relation.extendViewWidget
* Called when the relation viewWidget is created
*
* Example usage:
*
* $controller->bindEvent('relation.extendViewWidget', function ($widget, $field, $model) {
* if ($field === 'myRelationField') {
* $widget->addColumns([
* 'myNewColumn' => ['label' => 'My New Column'],
* ]);
* }
* });
*/
if ($this->viewWidget = $this->makeViewWidget()) {
$this->controller->bindEvent('relation.extendViewWidget', [$this->controller, 'relationExtendViewWidget']);
@@ -403,6 +416,21 @@ public function initRelation($model, $field = null)

/*
* Manage widget
*
* @event relation.extendManageWidget
* Called when the relation manageWidget is created
*
* Example usage:
*
* $controller->bindEvent('relation.extendManageWidget', function ($widget, $field, $model) {
* if ($field === 'myRelationField') {
* $widget->model->bindEvent('model.form.filterFields', function ($widget, $fields, $context) {
* if (isset($fields->myFormField)) {
* $fields->myFormField->hidden = true;
* }
* });
* }
* });
*/
if ($this->manageWidget = $this->makeManageWidget()) {
$this->controller->bindEvent('relation.extendManageWidget', [$this->controller, 'relationExtendManageWidget']);
@@ -412,6 +440,19 @@ public function initRelation($model, $field = null)

/*
* Pivot widget
*
* @event relation.extendPivotWidget
* Called when the relation pivotWidget is created
*
* Example usage:
*
* $controller->bindEvent('relation.extendPivotWidget', function ($widget, $field, $model) {
* if ($field === 'myRelationField') {
* $widget->addFields([
* 'myNewPivotField' => ['label' => 'My New Pivot Field'],
* });
* }
* });
*/
if ($this->manageMode === 'pivot' && $this->pivotWidget = $this->makePivotWidget()) {
$this->controller->bindEvent('relation.extendPivotWidget', [$this->controller, 'relationExtendPivotWidget']);
Loading