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]: Localized calculated value has wrong index within field collection #16718

Closed
studio1gmbh-pimcore opened this issue Mar 1, 2024 · 2 comments · Fixed by #16735
Closed
Assignees
Milestone

Comments

@studio1gmbh-pimcore
Copy link

studio1gmbh-pimcore commented Mar 1, 2024

Pimcore version

11.1.5

Steps to reproduce

  1. Create a field collection including a localized calculated value
  2. Create a simple calculator class, that returns the current index
    // ...
    public function compute(Concrete $object, CalculatedValue $context): string
    {
        return 'I have index ' . $context->getIndex();
    }
    // ...
  1. Set the calculator class in the calculated value
  2. Create a class using the field collection
  3. Create a new object and add field collection items

Actual Behavior

Index is always 0

image

Expected Behavior

Index should be same as the position within the field collection

image

This is probably related to #11816.

Inside the loop, the index must be updated every iteration, not just the first time, when $params['context']['containerKey'] is not set.

@kingjia90
Copy link
Contributor

Fixed by #16735
Thank you for suggesting the fix

@studio1gmbh-pimcore
Copy link
Author

@kingjia90 thx for fast fix!

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

Successfully merging a pull request may close this issue.

3 participants