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: README.md
+30-3Lines changed: 30 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,21 +164,36 @@ With this package your are also able to add a create button for the foreign CRUD
164
164
165
165
### Modal view
166
166
167
+
#### By route
168
+
167
169
By default the modals are loaded automatically by using `entity` in `on_the_fly` of the field definition, e.g. resulting in `backpack_url($field['on_the_fly']['entity']).'/ajax/create'` for the create modal.
168
170
169
171
You can overwrite this behavior for all modals by setting an attribute:
170
172
171
173
```
172
174
'on_the_fly' => [
173
175
'entity' => 'entity',
174
-
'create_modal' => 'route/to/modal/html',
175
-
'edit_modal' => 'route/to/modal/html',
176
-
'delete_modal' => 'route/to/modal/html',
176
+
'create_modal' => 'route/to/modal/html',
177
+
'edit_modal' => 'route/to/modal/html',
178
+
'delete_modal' => 'route/to/modal/html',
177
179
]
178
180
```
179
181
180
182
> Please be aware that by using this attributes you will be completely responsible for the content of the modal! The defined request has to provide valid HTML which is then filled in `<div class="modal-content"></div>`
181
183
184
+
#### By view
185
+
186
+
Instead of defining a route you can also use a custom view by:
187
+
188
+
```
189
+
'on_the_fly' => [
190
+
'entity' => 'entity',
191
+
'create_modal_view' => 'view.to.create.modal',
192
+
'edit_modal_view' => 'view.to.edit.modal',
193
+
'delete_modal_view' => 'view.to.delete.modal',
194
+
]
195
+
```
196
+
182
197
### Search logic
183
198
184
199
The "instant field" triggers the `ajaxIndex()` of the `EntityCrudController` where the field is defined and uses the fields `model` and `attribute` parameters to perform the search on the foreign model.
@@ -237,6 +252,18 @@ Instant Fields will try to auto-fill the select2 input after creating a new entr
237
252
]
238
253
```
239
254
255
+
### Passing current field values to foreign `EntityCrudController`
256
+
257
+
Sometimes you will need current values to be used for the creation of an foreign entity. You may define `serialize` with the IDs of the fields you need in the store request:
258
+
259
+
```
260
+
'on_the_fly' => [
261
+
'serialize' => ['type_id', 'name'],
262
+
]
263
+
```
264
+
265
+
So the current values of `type_id` and `name` will be available in the `$request` of the `ajaxStore` method of your foreign `EntityCrudController` (you will have to overwrite it).
266
+
240
267
### Fields
241
268
242
269
Publish the fields in your project and modify functionality
0 commit comments