[Bug] setupInlineCreateOperation does not overwrite the default form
See original GitHub issue# Bug report As mentioned in the “InlineCreate Operation” documentation (https://backpackforlaravel.com/docs/4.1/crud-operation-inline-create#how-to-use) I am trying to overwrite the form that appears as modal, but despite creating the setupInlineCreateOperation function in the related CRUD, I can’t get it to be effective.
### What I did I have two CRUDs: PageCrud and RouteCrud. In the PageCrud form I want to show a field of type “relationship” enabling the “inline_create” functionality so I can create by ajax new RouteCrud entities.
In RouteCrud I have defined:
protected function setupCreateOperation()
{
...
}
protected function setupInlineCreateOperation()
{
...
}
And this is the definition of the “relationship” field in PageCrud:
$this->crud->addField([
'name' => 'routes',
'label' => 'Rutas',
'type' => 'relationship',
'ajax' => true,
'inline_create' => [
'entity' => 'route',
'attribute' => 'slug',
],
'tab' => 'Rutas',
]);
### What I expected to happen By clicking the “+Add” link in the “relationship” field of PageCrud, I want the modal form defined in RouteCrud’s “setupInlineCreateOperation” function to be displayed.
### What happened The form predefined in “setupCreateOperation” is still displayed instead of the one defined in “setupInlineCreateOperation”.
Otherwise, everything works fine. I just can’t get it to show the form defined in “setupInlineCreateOperation” instead of the default one.
### What I’ve already tried to fix it I’ve tried to change definitions of the “relationship” field in case something wasn’t working right, but I can’t get it to work as intended. Am I missing a step? Or is it a bug in this functionality?
### Backpack, Laravel, PHP, DB version
When I run php artisan backpack:version
the output is:
PHP VERSION:
PHP 7.3.16 (cli) (built: Mar 17 2020 13:33:33) ( ZTS MSVC15 (Visual C++ 2017) x86 ) Copyright © 1997-2018 The PHP Group Zend Engine v3.3.16, Copyright © 1998-2018 Zend Technologies
LARAVEL VERSION:
v7.14.1@469b7719a8dca40841a74f59f2e9f30f01d3a106
BACKPACK VERSION:
4.1.7@dae5b308ede3f635d979f74b417982e8b1debca8
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thank you both for your help. I understand now what my mistake was: I was defining all the fields I needed (with “addField”) in both “setupCreateOperation” and “setupInlineCreateOperation”. As if they were independent definitions each one. When in fact I should use “setupCreateOperation” as a starting point for “setupInlineCreateOperation”, and therefore use “removeField” to for example remove fields, which is what I wanted to do.
Thanks for everything again.
The
setupInlineCreateOperation
it’s not how you define the form that shows, but how you manipulated the form.The form is grabbed as you said from createOperation, when using
setupInlineCreateOperation
you can delete/add fields etc modifying the setup we get from create.It indeed gets called.