Skip to content

Add options_editable option to select content_type fields - #1430

Open
greyskin wants to merge 6 commits into
locomotivecms:masterfrom
greyskin:content_types-select-options-editable
Open

Add options_editable option to select content_type fields#1430
greyskin wants to merge 6 commits into
locomotivecms:masterfrom
greyskin:content_types-select-options-editable

Conversation

@greyskin

Copy link
Copy Markdown

Adds a new boolean field option, options_editable (default true), to select content type fields. When set to false, admin users editing a content entry can no longer add new options to that field via the Back Office's "Edit options" screen — the field itself remains fully usable, just not extensible.

This mirrors the existing ui_enabled option available on has_many/many_to_many fields, though it's a distinct flag rather than a reuse of ui_enabled, since ui_enabled already has an unrelated, broader meaning (whole-field visibility in the entry form) that doesn't fit this use case.

Motivation: some sites want a fixed, curated list of select options that only developers can change via Wagon/YAML, while others want admins free to expand the list from the Back Office. Currently this isn't configurable per-field.

Changes:

  • lib/locomotive/custom_fields.rb — new options_editable field on the base Field model
  • app/api/locomotive/api/forms/content_type_field_form.rb — whitelist the new attribute
  • app/api/locomotive/api/entities/content_type_field_entity.rb — expose it for select fields
  • app/api/locomotive/api/resources/content_type_resource.rb — accept it as an API param
  • app/controllers/locomotive/custom_fields/select_options_controller.rb — enforce it (before_action, returns 403 if disabled) — this is the actual permission boundary, not just a UI nicety
  • app/helpers/locomotive/custom_fields_helper.rb — hide the "Edit options" link when disabled
  • Adds specs covering the new controller guard

Backward compatibility: defaults to true, so existing sites and fields are unaffected unless explicitly opted out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant