Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug] relationship field with ajax when editing does not allow searching #3032

Closed
DanielKimmich opened this issue Jul 15, 2020 · 3 comments
Closed
Assignees

Comments

@DanielKimmich
Copy link

Bug report

I am using the "relationship" field inside a "repeatable" field, with the "ajax" functionality set to true. The problem I have is that when editing the data, the search cannot be entered, but the option to select comes out. That does not happen when a new items is added.

What I did

My code

                [   'name'  => 'data8',
                    'label' => trans('contact.address.division'),
                    'type'  => 'relationship',
                    'wrapper' => ['class' => 'form-group col-md-6'],
                    'attributes' => ['id' => 'address_division'],
                    'model' => 'App\Models\WorldDivision', // foreign key model
                    'entity'    => 'addresses',
                    'attribute' => 'name',
                    'ajax' => true,
                    'multiple' => false,
                    'data_source'  => url($this->crud->route.'/fetch/division'),
                    'dependencies'  => ['data10'], //this select2 is reset to null
                    'minimum_input_length' => 0, // minimum before querying results
                    'default' => Config::get('settings.contact_division'),
                    'include_all_form_fields'  => false,
                ],

What I expected to happen

Attachment screenshot:
In add items:
image

In existing modify:
image

Backpack, Laravel, PHP, DB version

PHP VERSION:

PHP 7.4.7 (cli) (built: Jun 9 2020 13:36:15) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

LARAVEL VERSION:

v7.20.0@682ea946bc136aa686d5a64940ab3d4a24d5a613

BACKPACK VERSION:

4.1.14@f4a6ad91f2aa3760ffe963c5cd87d2b533803323

@DanielKimmich DanielKimmich changed the title [Bug] [Bug] relationship field with ajax when editing does not allow searching Jul 15, 2020
@pxpm
Copy link
Contributor

pxpm commented Jul 17, 2020

Hello @DanielKimmich

I am afraid I was not able to reproduce your issue.

What I did:

  • Added a repeatable field with a relationship field inside.
[    // Relationship
                'label'     => 'Relationship',
                'type'      => 'relationship',
                'name'      => 'products',
                'entity'    => 'products',
                'tab'       => 'Relationships',
                'ajax'      => true,
                'multiple' => false,
                'minimum_input_length' => 0,
                'data_source'       => backpack_url('monster/fetch/product'),
            ],

Screenshot_13

Anything more I should be looking at?

Best,
Pedro

@DanielKimmich
Copy link
Author

Thank you very much, I found the problem.
When you define "'attributes' => ['id' => 'address_division'],", the search option is removed and passed to a select.
I leave to you the analysis if that corresponds to a bug or not.

For now, I'm deleting the attribute.
Regards,

@pxpm
Copy link
Contributor

pxpm commented Jul 20, 2020

Indeed @DanielKimmich . ID's does not play well with repeatable. I suggest you to use some other data-attribute to store anything extra you need in field.

Going to close this.

Thanks, Pedro

@pxpm pxpm closed this as completed Jul 20, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants