statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Unlocalized field with default value written to secondary language markdown #2488

Open bendeca opened 4 years ago

bendeca commented 4 years ago

This happens with any field with either a default value set by the user in the fieldset editor or if the fieldtype has a default value by definition (e.g. toggle)

Describe the bug Whenever a field is not in the primary language markdown (eg. a newly added field) the default value of that field is written to the secondary language markdown file even if the field is unlocalizable. If subsequently the primary language is edited and saved, the unlocalized field is only written to the primary language markdown, the value in the secondary markdown remains unchanged and can't be changed through the control panel.

To Reproduce Steps to reproduce the behavior:

  1. Take any existing localized page with existing content.
  2. add a field foo to the fieldset of that page. You must either set a default value or select a fieldtype that has a default value by definition (eg. toggle, default: false)
  3. make any change to that page in the secondary language (before editing the primary language)
  4. your .md file of the secondary language will now contain: foo: default_value
  5. Edit the field in the primary language and the markdowns of the pages will look like this: primary: foo: not_default_value secondary: foo: default_value
  6. The value of foo in the secondary language can not be changed (in the control panel) anymore

Expected behavior unlocalized fields should never be saved to secondary language markdowns as to eliminate the possibility of the values diverging.

Environment details (please complete the following information):