Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Bug] Allow user to select multiple times the same pivot #5707

Closed
rezahmady opened this issue Oct 27, 2024 · 3 comments
Closed

[Bug] Allow user to select multiple times the same pivot #5707

rezahmady opened this issue Oct 27, 2024 · 3 comments
Assignees
Labels
Possible Bug A bug that was reported but not confirmed yet.

Comments

@rezahmady
Copy link

rezahmady commented Oct 27, 2024

after fix this reported issue 5635
this feature stopped working
Allow user to select multiple times the same pivot

@rezahmady rezahmady changed the title [Bug] Allow user to select multiple times the same pivot [Bug] Oct 28, 2024
@rezahmady rezahmady changed the title Allow user to select multiple times the same pivot [Bug] [Bug] Allow user to select multiple times the same pivot Oct 28, 2024
@pxpm
Copy link
Contributor

pxpm commented Oct 29, 2024

Hello @rezahmady thanks for the report.

Can you provide some reproduction steps ? (ideally a simple repository we can clone to test your code with only the relevant model/migrations and crud controllers to reproduce this scenario).

We have some tests in place, and they are passing

public function testBelongsToManyWithMultipleSameRelationIdAndPivotDataDynamicRelationship()

Cheers

@rezahmady
Copy link
Author

rezahmady commented Nov 16, 2024

my relation in Video model:

public function crew_people(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
    {
        return $this->belongsToMany(CrewPeople::class,'crew_people_video', 'video_id', 'crew_people_id')
            ->withPivot(['crew_role_id', 'id', 'star']);
    }

this is my field



                [
                    'name'          => 'crew_people',
                    'type'          => "relationship",
                    'label' => '',
                    'allow_duplicate_pivots' => true,
                    'new_item_label'  => trans('crew::lang.add_crew_people'),
                    'tab' => trans('crew::lang.crew_people_plural'),
                    'subfields'   => [
                        [
                            'name' => 'crew_role_id',
                            'label' => trans('crew::lang.crew_role_singular'),
                            'type' => "select2_from_array",
                            'options' => CrewRole::pluck('name', 'id')->toArray(),
                            'wrapper' => [
                                'class' => 'form-group col-md-4',
                            ],
                            'placeholder' => trans('crew::lang.crew_role_plural_placeholder'),
                        ],
                        [
                            'name' => 'star',
                            'label' => trans('crew::lang.crew_star'),
                            'type' => "switch",
                            'wrapper' => [
                                'class' => 'form-group col-md-2 pt-5',
                            ],
                        ]
                    ],
                    'pivotSelect'=> [
                        // 'attribute' => "title", // attribute on model that is shown to user
                        'label' => trans('crew::lang.crew_people_singular'),
                        'placeholder' => trans('crew::lang.crew_placeholder'),
                        'wrapper' => [
                            'class' => 'col-md-6',
                        ],
                        'inline_create' => true,
                        // note that just like any other select, enabling ajax will require you to provide an url for the field
                        // to fetch available options. You can use the FetchOperation or manually create the enpoint.
                        'ajax' => true,
                        'minimum_input_length'    => 0,
                        'data_source' => url('/api/crew/people'),
                    ],
                ]
            

but result

image

I can't choose Eddie (first item) twice

whene i remove this line in field properties is correct

'inline_create' => true,

the main problem is inline create

@pxpm pxpm added Possible Bug A bug that was reported but not confirmed yet. and removed triage labels Nov 18, 2024
@pxpm pxpm self-assigned this Nov 18, 2024
@pxpm
Copy link
Contributor

pxpm commented Dec 4, 2024

Thanks @rezahmady I was able to reproduce and fix the issue.

I've just released backpack/pro 2.2.28 with the fix. Please allow a few moments for our private repository to pick up the changes and you should be able to get the fixed version 👍

Let us know if you are still experiencing issues.

Cheers

@pxpm pxpm closed this as completed Dec 4, 2024
@github-project-automation github-project-automation bot moved this to Done in This week Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Possible Bug A bug that was reported but not confirmed yet.
Projects
Status: Done
Development

No branches or pull requests

2 participants