Entities 0.2.10: Translations no longer lost when a record is edited
Entities 0.2.10 fixes a data-loss bug in the admin record form on multi-language sites. Every language tab showed the same text, and saving the record deleted all its other translations.
The form loaded the record already merged into the admin’s own interface language, so the other languages were no longer there. All tabs showed that one language, and the next save wrote it back as the only one. A record in four languages edited once came back with one. The form now loads the record with all its languages, both when it opens and when it refreshes after a change elsewhere.
Sites that once had several languages and later turned the Languages module off had two more problems with such records: the form showed every field blank and then saved the blanks over the main language, and saved values could land under no language at all. The form now reads and saves the record’s main language.
The module also reports its version correctly again; it said 0.1.4.
Full release notes: Entities 0.2.10
0.2.10 · 29 July 2026
Fixed
-
The admin data form showed one language in every language tab, and deleted the rest on save.
Web.DataForm.handle_params/3loaded the record withEntityData.get!(uuid, lang: locale), wherelocaleis the admin’s own UI locale. That option runsresolve_language/2, which replaces the multilangdataJSONB with the single merged map for that locale —_primary_languageand every other language are gone from the struct. Two consequences, both reported as “translations aren’t in the admin, but they’re in the DB”:- Every language tab rendered the same text.
MultilangForm.get_lang_data/3asksMultilang.get_raw_language_data/2for the tab’s language; on a flattened map that returns the whole map regardless of which language was asked for, so all tabs showed whatever the admin’s UI locale resolved to. - The next save wrote the collapsed map back.
merge_multilang_data/4builds the newdatafrom this changeset, soput_language_data/3saw non-multilang data, rebuilt the structure around a single language, and the row lost the others permanently. A four-language record edited once came back with one.
The record is now loaded raw at all three sites (both
handle_params/3edit clauses and the:data_updatedrefresh inhandle_info/2). The entity is still loaded with:lang— that only localisesdisplay_name/descriptionfor the admin chrome and leavesfields_definitionalone. - Every language tab rendered the same text.
-
Web.DataFormno longer merges submitted values under anillanguage key when the Languages module is disabled but the row still carries multilangdata(languages configured once, later switched off).current_langis nil in that state; the newmerge_lang/2falls back to the row’s embedded_primary_language. Flat rows are unaffected — they have no embedded primary, so the merge keeps passing params straight through. -
The single-language layout rendered every custom field blank over a multilang row, then saved the blanks over the primary language. Same state as above (Languages module off, row still multilang), on the read side: that layout calls
FormBuilder.build_fields/3withlang_code: nil, so each field readsdata["field_key"]straight off the changeset — one level above where a multilang row keeps its values. The fields came up empty, and the following save merged those blanks under the embedded primary viamerge_lang/2, replacing that language’s real content. The newprimary_language_view/1hands the layout a flattened primary-language view to read from; input names are unchanged, so params still round-trip back under the primary key. Flat rows pass through untouched.
Changed
EntityData.resolve_language/2is documented as lossy and display-only, with an explicit warning never to build an update changeset from its result.list_tree/2’s:langoption points at it.
Entities 0.2.10. Install or update: {:phoenix_kit_entities, "~> 0.2"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.