Hi! I’m using LiveView to automatically generate slugs based on a form’s “Name” field. We do this by calling
put_change on the changeset inside the
This works perfectly for “new” forms, but on “edit” forms, there is an interesting bug:
The issue seems to be when we
put_change, Ecto compares the value to the existing value in the
data, and since it matches the original value, it’s removed completely from the
But LiveView seems to try to hold on to the current state in the form rather than falling back to the
data, and gets stuck on the previous version. Is there a way to fix this?
How are you showing the disabled slug input field? I think using
text_input(form, :slug, disabled: true)
should work. If you’re using
Ecto.Changeset.get_change/3, you can switch to using
You can use
force_change to have ecto not care if there was an actual change.
Thank you @LostKobrakai, that’s just what I need!
I also found it’s not LiveView’s fault: the old slug actually hangs around
input_value is preferring the
params version over the