diff --git a/Gemfile.lock b/Gemfile.lock index 9010f6a..eae2dde 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - advanced_select (0.1.9) + advanced_select (0.1.10) actionview (>= 7.1) railties (>= 7.1) stimulus-rails (>= 1.3) diff --git a/README.md b/README.md index c719da4..62d2139 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ AdvancedSelect is a small Rails engine for rendering an advanced select input wi - [Custom Option Content](#custom-option-content) - [Option Contract](#option-contract) - [Events](#events) +- [Disabled State](#disabled-state) - [API Reference](#api-reference) - [Local Development](#local-development) - [i18n](#i18n) @@ -791,6 +792,49 @@ const select = application.getControllerForElementAndIdentifier(element, "advanc select.currentValue // => ["3", "7"] ``` +### Disabled State + +Pass `disabled: true` to lock a field. It still renders its current selection — +the point is to show the value, not to hide it — but it cannot be opened, +searched, or cleared, and its value is **left out of the form**: + +```erb +<%= advanced_select_tag( + "record[item_id]", + id: "record_item_id", + selected: selected_option, + options: options, + placeholder: "Choose an item", + disabled: true +) %> +``` + +This matches a native `