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

Currency field not compatible with resolve logic #89

Closed
ragingdave opened this issue Oct 17, 2019 · 4 comments · Fixed by #90
Closed

Currency field not compatible with resolve logic #89

ragingdave opened this issue Oct 17, 2019 · 4 comments · Fixed by #90

Comments

@ragingdave
Copy link
Collaborator

The Currency field in nova has by default a displayUsing which will autoformat an empty value to something like USD 0.00 which then can break storage. It looks like this has to be a part of the resolve switch to handle currency via a direct resolve call rather than delegating.

@wize-wiz
Copy link
Contributor

@ragingdave I'm unable to reproduce. Default currency is not applied when value is null, which nova translates to --. Could you supply an example of your implementation?

@ragingdave
Copy link
Collaborator Author

Hmm... Well it's a pretty simple setup:

        NovaDependencyContainer::make([
            Currency::make('price')
                ->hideFromIndex(),
        ])->dependsOn('attr', 'T'),

It would seem that I was incorrect in the assumption about empty being formatted. It's actually when the underlying value of the currency field is 0.00, the field is treated as empty, and is formatted to be USD 0.00 instead of just 0.00. This used to be a bug in nova but was fixed and can confirm that when this field isn't wrapped by this dependency container it works as expected.

So to be clear the case that is failing is when the underlying value of the field is 0.00. The UI on the edit page acts as though there is no value and the field is left blank. If this container is removed from wrapping the Currency field, the value on the edit page is shown appropriately.

The related nova-issue is laravel/nova-issues#514.

@wize-wiz
Copy link
Contributor

@ragingdave Even it if closed automatically, can you confirm 1.2.8 solves it? If not, just open a new issue.

@ragingdave
Copy link
Collaborator Author

Will look into testing it tomorrow. Thanks for the quick work!

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 a pull request may close this issue.

2 participants