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] Pro: phone field not properly indexed within subfields of a relationship #5408

Open
daPhantom opened this issue Dec 20, 2023 · 0 comments
Labels

Comments

@daPhantom
Copy link

daPhantom commented Dec 20, 2023

Bug report

Since I do not have access to the pro repository I will raise this issue here.

What I did

Defined a relationship field during Create and Update operation and included two subfields with the type of text and phone.

What I expected to happen

When I click "add entry" within the UI all actual HTMl fields are indexed properly like name="parent[0][name]" and name="parent[0][phone]" and all validation rules and save / update logic will be applied correctly.

What happened

The -1 from the field name is not properly translated to a working index on the HTML field itself and stays -1 for phone fields when adding entries via the "add entry" button.

This breaks validation for properly indexed fields, since there is now also a "-1" input field for everything else expected and therefore the entity is not saved but more or less duplicated after submitting the request.

Before submit:

<!-- text field -->
<div ... bp-field-name="parent.-1.name" ...>
    <input type="text" name="parent[1][name]" value="" class="form-control" data-repeatable-input-name="name" data-row number="2" change-event-applied="true">
</div>

<!-- phone field -->
<div ... bp-field-name="parent.-1.phone" ...>
    <input type="hidden" name="parent.-1.phone">`
</div>

After submit there are two entries with "1" and "-1" as index.

What I've already tried to fix it

Workaround would be to use text fields instead. Fix is probably somewhere buried beneath java script.

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there?

yes

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 8.2.12 (cli) (built: Oct 26 2023 17:33:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.12, Copyright (c) Zend Technologies
with Zend OPcache v8.2.12, Copyright (c), by Zend Technologies
with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans

LARAVEL VERSION:

10.38.1.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.2.2
backpack/crud: 6.4.2
backpack/devtools: 2.0.3
backpack/generators: v4.0.2
backpack/permissionmanager: 7.1.1
backpack/pro: 2.0.20
backpack/revise-operation: 2.0.0
backpack/theme-tabler: 1.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

1 participant