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 Closures in MaxValue and MinValue #74

Merged

Conversation

remiebelingmerifond
Copy link
Contributor

I encountered issues similar to #72 when trying to inject a service into a closure passed to the minValue method.

I compared the MoneyInput::minValue method with its counterpart in TextInput::getMinValue and noticed that $this->evaluate($value) was being called too early in the MoneyInput implementation.

This was what caused the Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization Error.

As the closure is evaluated in TextInput::getMinValue anyway, there seems to be no need for minValue or maxValue to evaluate $value at all.

So i aligned the way minValue and maxValue works to the way TextInput does it.

After these changes:

  • Closures that depend on Laravel's dependency injection or Filament's closure injection features work correctly.
  • Passing integers values remains fully functional.
  • Issue gte and lte support #72 is very likely resolved

@pelmered
Copy link
Owner

pelmered commented Dec 4, 2024

This looks good. Thank you very much for your contribution!

@pelmered
Copy link
Owner

pelmered commented Dec 4, 2024

And don't worry about Scrutinizer. It didn't play well with Pest for test suite so I removed it now.

@pelmered pelmered merged commit 1549291 into pelmered:main Dec 4, 2024
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants