elixirmoney / money

Elixir library for working with Money safer, easier, and fun... Is an interpretation of the Fowler's Money pattern in fun.prog.
https://hex.pm/packages/money/
MIT License
826 stars 139 forks source link

Extracting value from changeset to display number only in input #215

Open SamuelMTDavies opened 7 months ago

SamuelMTDavies commented 7 months ago

I have an issue where a user inputs a value into a numerical input. If an issue occurs further down the call chain and the changeset is not valid the numerical input then displays the value with the currency symbol.

Is there a way to extract and display the value only?

<.input field={f[:amount]} type="donation" required />

Input before changeset: Screenshot 2024-01-30 at 14 05 06

Input if another input causes invalid changeset and page is re-rendered:

Screenshot 2024-01-30 at 14 05 20

How do I ensure the amount is extracted from the changeset when this happens? Because this way if the form was submitted again would then cause an error on the amount input now because of the symbol.

lessless commented 1 week ago

@SamuelMTDavies did you try https://elixirforum.com/t/edit-and-update-using-elixir-money-library/25218/11 ?