Currency Field Type
This module provides a field type for storing currency information based on the ISO 4217 standard. It allows editors to select currencies from a predefined list, ensuring accuracy and consistency, and includes support for withdrawn currencies.
A field type for currencies, following ISO 4217. Add it to any entity and editors pick a currency from a list of every code in the standard, rather than typing one into a plain text field and hoping.
The module is small and feature-complete. It does one thing, has no dependencies beyond Drupal core, and is maintained for fixes rather than new features.
Features
- A
currency_fieldfield type, with a select widget and a formatter, available on any fieldable entity. - The complete ISO 4217 list bundled as data — alphabetic code, numeric code, currency name, issuing entity, and minor unit — so there is no API call and no external service to depend on.
- Withdrawn currencies carry their withdrawal date, so historical records stay valid instead of failing validation.
- Options can be keyed and labelled by any pair of those columns, so a field can store alphabetic codes while showing full currency names, or store numeric codes for a system that expects them.
Requirements
Drupal 8, 9, 10 or 11. Nothing else.
Installation
composer require drupal/currency_field, then enable the module. See Installing modules for the longer version.
Usage
Add a field of type Currency to any entity bundle through Manage fields. Choose the select widget on Manage form display, and set the label format on Manage display.
For developers
Two helpers are available if you need the currency data outside a field:
currency_field_currencies()returns the full decoded list.currency_field_currency_options()returns an options array, keyed and labelled by whichever columns you ask for —AlphabeticCode,NumericCode,Currency,Entity,MinorUnitorWithdrawalDate.
The source data comes from the currency-codes dataset and lives in currencies.yml. Issues and merge requests for data corrections are welcome.
Used by
GTFS Utilities uses it in its GTFS Fares submodule to store fare product prices. It is not specific to that use — it is a general-purpose field.