On the initial render of a form in LiveView (or Phoenix, in general), the type of the input_value(form, field) is the same as the type of the field in the schema. When a user inputs a value, however, form fields are cast to a string and so the type of input_value(form, field) is always string.
So, for example, suppose a form has a field num whose type is integer, and in the view we use input_value(form, :num) to get the number and render some preview based on the num, then on a change to num, input_value(form, :num) will return the string representation of an the integer, and so the compiler will complain with invalid argument as the expected integer is now a string.
The same happens with DateTime fields. Is there a known way of casting form fields back to their original types once they’ve been passed through a changeset?
(Apologies for the long-winded question - couldn’t figure out how to frame my problem better)