Closed tostr7191 closed 1 year ago
For anyone having the same issue, this is what fixed it for me:
instead of defining the form field like this:
<%= text_input f, :amount, type: "number", placeholder: "0" %>
change the type from "number" to "text" like this:
<%= text_input f, :amount, type: "text", placeholder: "0" %>
You can also just omit type: "text"
as it is the default type of a text_input
.
Seems like this should be closed.
Hi
I have created a basic phoenix project, my schema has two integer fields and the schema definition looks like this:
On the default generated views (in my case
/expenses/new
, any value that I put into one of the Money-fields gets reset to an empty value as soon as I jump to a different field and trigger validation there. Below is the screenshot after I have input "1234" into "Amount" then TAB to jump to "Vat Amount" and as soon as I input 1 into "Vat Amount" the value in "Amount" gets set to empty and the validation (can't be blank) shows.I have recreated this in a fresh project with nothing added except for:
mix phx.gen.live Tally Expense expenses telegram_id telegram_nick file_name amount:integer vat_amount:integer
I have to admit that I am very new to phoenix, it might be that I am missing something obvious here.
Edit: If I remove
phx_change: "validate",
fromlib/testme_web/live/expense_live/form_component.html.leex
it works, gets saved to database correctly and also renders correctly. It's just the validation that does for some reason throws away the data sometimes.