Skip to content

Commit

Permalink
fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Mar 8, 2022
1 parent 4f61360 commit 7e9f37f
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,40 +134,40 @@ If you are extending a plugin and want the added fields in the backend to be tra

```
public function boot() {
Event::listen('backend.form.extendFieldsBefore', function($widget) {
// Only apply this listener when the Page controller is being used
if (!$widget->getController() instanceof \Winter\Pages\Controllers\Index) {
return;
}
// Only apply this listener when the Page model is being modified
if (!$widget->model instanceof \Winter\Pages\Classes\Page) {
return;
}
// Only apply this listener when the Form widget in question is a root-level
// Form widget (not a repeater, nestedform, etc)
if ($widget->isNested) {
return;
}
// Add fields
$widget->tabs['fields']['viewBag[myField]'] = [
'tab' => 'mytab',
'label' => 'myLabel',
'type' => 'text'
];
// Translate fields
$translatable = [
'viewBag[myField]'
];
// Merge the fields in the translatable array
$widget->model->translatable = array_merge($widget->model->translatable, $translatable);
});
Event::listen('backend.form.extendFieldsBefore', function($widget) {
// Only apply this listener when the Page controller is being used
if (!$widget->getController() instanceof \Winter\Pages\Controllers\Index) {
return;
}
// Only apply this listener when the Page model is being modified
if (!$widget->model instanceof \Winter\Pages\Classes\Page) {
return;
}
// Only apply this listener when the Form widget in question is a root-level
// Form widget (not a repeater, nestedform, etc)
if ($widget->isNested) {
return;
}
// Add fields
$widget->tabs['fields']['viewBag[myField]'] = [
'tab' => 'mytab',
'label' => 'myLabel',
'type' => 'text'
];
// Translate fields
$translatable = [
'viewBag[myField]'
];
// Merge the fields in the translatable array
$widget->model->translatable = array_merge($widget->model->translatable, $translatable);
});
}
```
## Model translation
Expand Down

2 comments on commit 7e9f37f

@mjauvin
Copy link
Member Author

@mjauvin mjauvin commented on 7e9f37f Mar 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjauvin
Copy link
Member Author

@mjauvin mjauvin commented on 7e9f37f Mar 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #24

Please sign in to comment.