question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pabloblazquezcommented, Jun 15, 2020

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.

1reaction
pxpmcommented, Jun 15, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django - Change the default error messages for a form
I'm trying to create a simple ajax form with a validation summary so I can't have the error message 'This field is required'...
Read more >
Default Text - How to stop default overwrite of text fields
Hello, Context: I am developing an app, the intent of which is to allow users to Submit Documentation via a form which has...
Read more >
Solved: Missing 0's are overwritten by Set Default Grade
I don't think I did anything wrong - I think this is a bug in Canvas not seeing the missing assignments as already...
Read more >
How can I override the default form text? - Cognito Forms
In Cognito Forms, you can manually replace the text that appears in fields, error messages, and other areas of your form. Many text...
Read more >
Revision of Form that does not overwrite original form creates ...
Have you tried this idea? 1) The first thing you need to do is disable the save/save as buttons, and instead of using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found