How to manually insert a key into the changeset?

Hello everyone,

I have two input fields for a form. When I changed only one of the input fields, only one the changed input field is in the changeset? How do I put the NON-CHANGED input field into the changeset as well? put_change doesnt seem to works


You can force changes in various ways like with force_change/3 or the :force_change option on cast/4. In most cases that shouldn’t be needed though.


What’s the problem you are trying to solve by doing so?

Technically the non-changed values are in the changeset via the data key. You are able to access them with the get_field function (see also fetch_field for completeness). The put_change function will only put an actual change into the changes key, otherwise it would be a lie to call it “changes”!