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

HTML form saving is broken with MoneyIntegerCast #166

Open
Jamesking56 opened this issue Nov 11, 2024 · 1 comment
Open

HTML form saving is broken with MoneyIntegerCast #166

Jamesking56 opened this issue Nov 11, 2024 · 1 comment

Comments

@Jamesking56
Copy link

Jamesking56 commented Nov 11, 2024

Hello!

If you use MoneyIntegerCast on your model, e.g.:

protected $casts = [
    'price' => MoneyIntegerCast::class . ':GBP',
];

and given the form:

<form action="somewhere" method="post">
    @csrf
	<input type="number" step="0.01" />
</form>

If you enter in the value 1 into the form, expecting £1.00 to be result. You get £0.01 instead...

However, if you enter 1.00 into the form, expecting £1.00 to be result. You do get £1.00.

My users keep putting in 1 and expecting £1.00...

@Jamesking56
Copy link
Author

If you set $forceDecimals to true, this presents a new problem.

It fixes the above issue, entering 1 does indeed save as £1.00.

However, reading the value back out of the database sets it to £100...

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

No branches or pull requests

1 participant