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

Handle cases where Wizard Step is not found (hidden steps) #12054

Merged
merged 5 commits into from Mar 27, 2024

Conversation

AlexisSerneels
Copy link
Contributor

Description

Found related issue : #4916 (comment)

I encountered the same exception in my project:

Undefined array key -1 at /vendor/filament/forms/src/Components/Wizard.php:78

It happens because the method findIndex(...)returns -1 if no item is found.
Thus the getStepIndex()returns -1 which does not exists and throws a 500 Exception.

This PR fixes this issue by returning the first Wizard step instead.

Visual changes

None

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@danharrin
Copy link
Member

To be honest, it doesn't feel like you've tested this. index = this.getSteps()[0] assigns the ID of the step instead of its index doesn't it? Doesn't it just need to be index = 0?

@danharrin danharrin added the bug Something isn't working label Mar 27, 2024
@danharrin danharrin added this to the v3 milestone Mar 27, 2024
@AlexisSerneels
Copy link
Contributor Author

Sorry about the wrong copy/paste into Github Issue PR. You are correct.
Thank you for the strict comparison operator correction.

@danharrin danharrin merged commit de207f1 into filamentphp:3.x Mar 27, 2024
10 checks passed
@AlexisSerneels AlexisSerneels deleted the patch-1 branch March 27, 2024 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants