Skip to content

Default Custom Field Format Design

Goal

New custom-field forms default field format to visible option Text, represented internally by string.

Current Behavior

CustomFieldsController#build_new_custom_field creates a custom field with blank field_format. Format options are sorted by localized label. Since no option matches blank value, browser displays and submits first option, currently Address - Google map in English.

Design

Set field_format to string while building a new custom field, before applying submitted safe attributes. Submitted format remains authoritative, including AJAX form refreshes and create requests.

This belongs in core controller lifecycle because default applies to every custom-field subtype. Extension patching would override private controller behavior and be more fragile than minimal core change.

Scope

  • Change only new custom-field initialization.
  • Preserve localized alphabetical format ordering.
  • Preserve explicitly submitted formats.
  • Do not change existing custom fields, database defaults, API persistence, or translations.

Testing

Controller specs verify:

  • initial new form assigns string;
  • explicitly submitted field format remains selected.