# `Backpex.Fields.Currency`
[🔗](https://github.com/naymspace/backpex/blob/0.18.3/lib/backpex/fields/currency.ex#L2)

A 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` (`t: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 `:before` or `:after`. The default value is `:before`.

* `:symbol_space` (`t:boolean/0`) - Add space between the symbol and the number. The default value is `false`.

* `:radix` (`t: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` (`t: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](https://hex.pm/packages/money) library, your schema might look like this:

    schema "article" do
      field :price, Money.Ecto.Amount.Type
      ...
    end

## Example

    @impl Backpex.LiveResource
    def fields do
      [
        price: %{
          module: Backpex.Fields.Currency,
          label: "Price",
          unit: "€",
          radix: ",",
          thousands_separator: "."
        }
      ]
    end

# `config_schema`

Returns the schema of configurable options for this field.

This can be useful for reuse in other field modules.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
