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

Fix empty collection first item index #6200

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

zorn-v
Copy link
Contributor

@zorn-v zorn-v commented Mar 14, 2024

Currently data-num-items does not denotes actually items count, and in fact it is 0 for empty collection AND collection with 1 item.
Because of this first item of empty collection obtain index 1
And if there validation violations on new created collection, indexes are shifted by 1
Because field names looks like Entity[collection][1][field] for very first item, but validation violation is like data.collection[0].field

PS. This PR does not include compiled assets via npm run build

@zorn-v
Copy link
Contributor Author

zorn-v commented Mar 14, 2024

Other possible fix is just change in form theme collection_row block without js editing (as I do in my project for now)

'data-num-items': form.children is empty ? 0 : max(form.children|keys),

to

'data-num-items': form.children is empty ? -1 : max(form.children|keys),

but "num items" should contain actual items count I think

@javiereguiluz javiereguiluz added this to the 4.x milestone Mar 14, 2024
@javiereguiluz javiereguiluz merged commit c1d37bd into EasyCorp:4.x Mar 14, 2024
11 checks passed
@javiereguiluz
Copy link
Collaborator

Thanks @zorn-v. While merging, I run make build-assets to rebuild the assets, so everything should be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants