Backpex.Fields.Currency (Backpex v0.16.1)
View SourceA field for handling a currency value.
Field-specific options
See Backpex.Field for general field options.
:debounce- Timeout value (in milliseconds), "blur" or function that receives the assigns.:throttle- Timeout value (in milliseconds) or function that receives the assigns.:unit(String.t/0) - Unit to display with the currency value, e.g. '€'. The default value is"$".:unit_position- Position of the unit relative to the value, either:beforeor:after. The default value is:before.:symbol_space(boolean/0) - Add space between the symbol and the number. The default value isfalse.:radix(String.t/0) - Character used as the decimal separator, e.g. ',' or '.'. Make sure this value matches the one you've configured in your Money library. The default value is".".:thousands_separator(String.t/0) - Character used as the thousands separator, e.g. '.' or ','. Make sure this value matches the one you've configured in your Money library. The default value is",".
Schema
Backpex expects you to use a Money library or a similar approach for handling currency values and dumping / casting them correctly in your database schema.
Ensure that your schema field is set up to handle the currency type appropriately.
For example, if you are using the Money library, your schema might look like this:
schema "article" do
field :price, Money.Ecto.Amount.Type
...
endExample
@impl Backpex.LiveResource
def fields do
[
price: %{
module: Backpex.Fields.Currency,
label: "Price",
unit: "€",
radix: ",",
thousands_separator: "."
}
]
end
Summary
Functions
Returns the schema of configurable options for this field.