You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
andphone
.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]"
andname="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:
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
The text was updated successfully, but these errors were encountered: