# 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 7.3.16 (cli) (built: Mar 17 2020 13:33:33) ( ZTS MSVC15 (Visual C++ 2017) x86 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies
v7.14.1@469b7719a8dca40841a74f59f2e9f30f01d3a106
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps _a lot_ in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication channels:
backpack-for-laravel tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
--
Justin Case
The Backpack Robot
Hmmm I agree @pabloblazquez - I would expect it to work that way too. I've created PR #2932 to fix this, but... I'm not 100% sure it's actually needed. AFAIK setupInlineCreateOperation() should be called automatically...
@pxpm is it possible that it's because the route defines the operation as InlineCreate instead of inlineCreate? Maybe that's why it doesn't get called?!
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.
public function setupInlineCreateOperation() {
$this->crud->removeField('your_field_name');
$this->crud->addField('your_field');
}
It indeed gets called.
Following-up on @pxpm 's response. Sorry @pabloblazquez I must have misread your issue.
To choose a different view to be loaded by the inline create modal, you can either:
a) create a new modal file in your resources/views/vendor/backpack/crud/fields/relationship/inline_create_modal.blade.php - it would overwrite it for ALL inlineCreate operations.
b) overwrite the getInlineCreateModal() function in your CrudController - this would only apply for the CrudController you're in:
/**
* Returns the HTML of the create form. It's used by the CreateInline operation, to show that form
* inside a popup (aka modal).
*/
public function getInlineCreateModal()
{
if (! request()->has('entity')) {
abort(400, 'No "entity" inside the request.');
}
return view(
'crud::fields.relationship.inline_create_modal',
[
'fields' => $this->crud->getCreateFields(),
'action' => 'create',
'crud' => $this->crud,
'entity' => request()->get('entity'),
'modalClass' => request()->get('modal_class'),
'parentLoadedFields' => request()->get('parent_loaded_fields'),
]
);
}
As @pxpm mentioned above, you can overwrite:
storeInlineCreate()setupInlineCreateOperation() methodI'm pretty sure the above treats all needs, so I'm going to close this, and make a note to add all the explanations above to the docs. Let me know if this is not the case and we'll reopen.
Cheers!
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.