From 024800b6270b005476dc434b944eea219c891f0e Mon Sep 17 00:00:00 2001 From: Kepi Date: Wed, 28 Jan 2026 19:43:03 +0100 Subject: [PATCH] Add readonly support to Backpex.Fields.Currency --- guides/fields/readonly.md | 1 + lib/backpex/fields/currency.ex | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/guides/fields/readonly.md b/guides/fields/readonly.md index 68aabc6a2..9df4116f2 100644 --- a/guides/fields/readonly.md +++ b/guides/fields/readonly.md @@ -14,6 +14,7 @@ On edit view, readonly is supported for: - `Backpex.Fields.Number` - `Backpex.Fields.Text` - `Backpex.Fields.Textarea` +- `Backpex.Fields.Currency` ## Configuration diff --git a/lib/backpex/fields/currency.ex b/lib/backpex/fields/currency.ex index 2e4801a0b..e7233a248 100644 --- a/lib/backpex/fields/currency.ex +++ b/lib/backpex/fields/currency.ex @@ -8,6 +8,10 @@ defmodule Backpex.Fields.Currency do doc: "Timeout value (in milliseconds) or function that receives the assigns.", type: {:or, [:pos_integer, {:fun, 1}]} ], + readonly: [ + doc: "Sets the field to readonly. Also see the [panels](/guides/fields/readonly.md) guide.", + type: {:or, [:boolean, {:fun, 1}]} + ], unit: [ doc: "Unit to display with the currency value, e.g. '€'.", type: :string, @@ -107,6 +111,8 @@ defmodule Backpex.Fields.Currency do unit={@field_options[:unit]} unit_position={@field_options[:unit_position]} symbol_space={@field_options[:symbol_space]} + readonly={@readonly} + disabled={@readonly} aria-labelledby={Map.get(assigns, :aria_labelledby)} />