Add options_editable option to select content_type fields - #1430
Open
greyskin wants to merge 6 commits into
Open
Add options_editable option to select content_type fields#1430greyskin wants to merge 6 commits into
greyskin wants to merge 6 commits into
Conversation
… content_type_field_entity.rb
… select_options_controller.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new boolean field option,
options_editable(defaulttrue), toselectcontent type fields. When set tofalse, 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_enabledoption available onhas_many/many_to_manyfields, though it's a distinct flag rather than a reuse ofui_enabled, sinceui_enabledalready 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
selectoptions 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— newoptions_editablefield on the baseFieldmodelapp/api/locomotive/api/forms/content_type_field_form.rb— whitelist the new attributeapp/api/locomotive/api/entities/content_type_field_entity.rb— expose it forselectfieldsapp/api/locomotive/api/resources/content_type_resource.rb— accept it as an API paramapp/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 nicetyapp/helpers/locomotive/custom_fields_helper.rb— hide the "Edit options" link when disabledBackward compatibility: defaults to
true, so existing sites and fields are unaffected unless explicitly opted out.