You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 6.x/crud-fields.md
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1782,20 +1782,29 @@ CRUD::field([
1782
1782
1783
1783
**That's it.** Backpack now will save those additional inputs on the pivot table.
1784
1784
1785
-
Additionally, if you want to change something about the primary select, you can do that using the `pivotSelect` attribute:
1785
+
#### Configuring the Pivot Select field
1786
+
If you want to change something about the primary select (the pivot select field created by Backpack), you can do that using the `pivotSelect` attribute:
1786
1787
1787
1788
```php
1788
1789
CRUD::field([
1789
1790
'name' => 'companies',
1790
1791
'type' => "relationship",
1791
1792
'subfields' => [ ... ],
1792
-
// ..
1793
+
// you can use the same configurations you use in any relationship select
1794
+
// like making it an ajax, constraining the options etc.
1793
1795
'pivotSelect'=> [
1794
-
// 'ajax' => true,
1795
1796
'placeholder' => 'Pick a company',
1796
1797
'wrapper' => [
1797
1798
'class' => 'col-md-6',
1798
1799
],
1800
+
// by default we call a $model->all(). you can configure it like in any other select
1801
+
'options' => function($model) {
1802
+
return $model->where('type', 'primary');
1803
+
},
1804
+
// note that just like any other select, enabling ajax will require you to provide an url for the field
1805
+
// to fetch available options. You can use the FetchOperation or manually create the enpoint.
0 commit comments