Cldr.HTML.Currency.select

You're seeing just the function select, go back to Cldr.HTML.Currency module for more information.
Link to this function

select(form, field, options \\ [])

View Source

Specs

select(
  form :: Phoenix.HTML.Form.t(),
  field :: Phoenix.HTML.Form.field(),
  select_options()
) ::
  Phoenix.HTML.safe()
  | {:error, {Cldr.UnknownCurrencyError, binary()}}
  | {:error, {Cldr.UnknownLocaleError, binary()}}

Generate an HTML select tag for a currency list that can be used with a Phoenix.HTML.Form.t.

Arguments

  • A Phoenix.HTML.Form.t() form

  • A Phoenix.HTML.Form.field() field

  • A Keyword.t() list of options

Options

For select options see Phoenix.HTML.Form.select/4

  • :currencies defines the list of currencies to be displayed in the the select tag. The list defaults to the currencies returned by Money.known_tender_currencies/0 if the package ex_money is installed otherwise it is the list returned by Cldr.known_currencies/0

  • :locale defines the locale to be used to localise the description of the currencies. The default is the locale returned by Cldr.get_locale/1

  • :backend is any backend module. The default is Cldr.default_backend!/0

  • :mapper is a function that creates the text to be displayed in the select tag for each currency. It is passed the currency definition Cldr.Currency.t as returned by Cldr.Currency.currency_for_code/2. The default function is &({&1.code <> " - " <> &1.name, &1.code})

  • :selected identifies the currency that is to be selected by default in the select tag. The default is nil. This is passed unmodified to Phoenix.HTML.Form.select/4

  • :prompt is a prompt displayed at the top of the select box. This is passed unmodified to Phoenix.HTML.Form.select/4

Examples

 => Cldr.HTML.Currency.select(:my_form, :currency, selected: :USD)
 => Cldr.HTML.Currency.select(:my_form, :currency, currencies: ["USD", "EUR", :JPY], mapper: &({&1.name, &1.code}))