Warp Input demo — phone numbers, addresses, money, IDs, signatures and form helpers for Filament. Change or delete anything; the data is reset every hour. warpui.com About Warp Input Docs Ask a question Support
Skip to content

Money

MoneyInput replaces TextInput for amounts. It writes each amount the way the screen’s language writes numbers, uses the currency’s decimal places, and saves a clean decimal string such as '1234.50' (or whole cents). This panel’s currency is the US dollar.

Digits grouped as you type

Commas appear while you type. When you leave the field, the amount gets the currency’s decimal places. Without ->currency(), the field uses the panel’s currency (->currency('USD') on the plugin).

Note: Try it

Type 1234567.8 — it shows 1,234,567.8 while you type. Click outside the field: it becomes 1,234,567.80. “Show what would be saved” shows "1234567.80".

$

Each currency’s decimal places and symbol

->currency('EUR') sets the currency. Yen has no decimals, the euro has 2 and the Kuwaiti dinar has 3. The symbol is placed the way the screen’s language writes it.

Note: Try it

Type 1234.5 in all three fields and click outside each one: 1,234.50 euros, 1,235 yen (rounded) and 1,234.500 dinars.

€

¥

KWD

Short forms such as 1.5k

Short forms of the screen’s language are read: 1.5k, 2.5M and 3 bn in English; 3万 and 1億2000万 on a Japanese screen. Short forms of other languages are refused.

Note: Try it

Type 1.5k and click outside the field: it becomes 1,500.00. Then type 2.5M: 2,500,000.00. On this English screen, 3万 is refused.

$

Pasted amounts in other formats

An amount copied from an email or a spreadsheet is read even when it is written another way: a German 1.234,56, a symbol ($1,200) or full-width digits (1234).

Note: Try it

Paste 1.234,56: it becomes 1,234.56. Paste $1,200: it becomes 1,200.00.

$

Negative amounts

A minus is read in the ways accountants write it: -5, (5) in brackets and ▲5 (the Japanese way).

Note: Try it

Type (25) and click outside the field: it becomes -25.00. Type ▲25: the same.

$

Lowest and highest amount

->minValue(0) and ->maxValue(10000) work as on TextInput. They check the number, not the text with commas.

Note: Try it

Type -5 and press “Show what would be saved”: an error says the amount must be at least 0. Then type 12000: an error says it must not be greater than 10000.

$

No full-width digits from the Japanese keyboard

Money fields are type="tel": the browser turns the Japanese, Chinese or Korean input method off, and phones show the number pad. This field is ->type('text'), so the input method works and 3万 can be typed on a Japanese screen.

Note: Try it

Switch the screen to Japanese with the language menu at the top. In this field, turn the input method on, type 3万 and click outside the field: it becomes 30,000. In the other money fields of this page, the input method stays off.

¥

Rounding

Amounts with too many decimals are rounded half up by default. ->rounding(Rounding::Down) cuts the extra digits off; Up and HalfEven are also there.

Note: Try it

Type 12.349 and click outside the field: it becomes 12.34 (half up would give 12.35).

$

Saved in cents

->storeAsMinorUnits() saves a whole number of cents, for an integer column. Saved cents are read back the same way.

Note: Try it

Type 12.34 and press “Show what would be saved”: 1234.

$

The currency from another field

->currencyField('currency') reads the currency from a select in the same form. When it changes, the digits and the symbol change straight away.

Note: Try it

Type 1234.5 (euros: 1,234.50). Then choose Japanese yen: it becomes 1,235. Choose Kuwaiti dinar and type 1234.5 again: 1,234.500.

€

Tax included or not

->tax(rate: 6.25) adds the “Excl. tax” switch next to the amount and shows the other side under the field. The field saves the amount before tax; ->netField(), ->taxField() and ->grossField() also save the other values.

Note: Try it

Type 100: under the field, “With tax $106.25 · Tax (6.25%) $6.25”. Click “Excl. tax” to switch it to “Incl. tax”: now 100 is read as the price with tax. Press “Show what would be saved”: 94.12 before tax, 5.88 tax, 100.00 with tax.

$

Prices that already include tax

->tax(rate: 6.25, included: true) starts the switch at “Incl. tax” and saves the amount with tax in the field’s own column.

Note: Try it

Type 106.25: under the field, “Before tax $100.00 · Tax (6.25%) $6.25”. Press “Show what would be saved”.

$

The tax rate from another field

->taxRateField('tax_rate') reads the rate from a select, for Japan’s 10% and 8% (food). ->rounding(Rounding::Down) rounds the tax down to the yen, a common choice in Japan.

Note: Try it

Type 1000: tax ¥90 at 10% (rounded down from 90.9). Then choose 8%: tax ¥74.

¥

Without the switch

->taxToggle(false) removes the switch: the amount is always read as ->tax() says (here before tax). The amount with tax is still shown under the field.

Note: Try it

Type 100: under the field, “With tax $106.25”. There is no switch to click.

$

An estimate in another currency

->showConverted('USD') shows under the field what the amount is worth in dollars, at the European Central Bank’s rate of the day. The saved amount does not change. The panel can use its own rates or turn this off with ->exchangeRates().

Note: Try it

Type 10000 and wait a moment: under the field, “About $… at the ECB rate of …”. Press “Show what would be saved”: still 10000 yen.

¥

The check without the field

The Money rule checks an amount from an API or an import: new Money(currency: 'JPY', min: 0) accepts a number with at most the currency’s decimals. This field is a plain TextInput with that rule.

Note: Try it

Type 12.5 and press “Show what would be saved”: an error, because yen has no decimals. Type 1250: accepted.

Saved amounts in tables and details

MoneyColumn and MoneyEntry show a saved amount with its currency’s digits and symbol. ->currencyColumn('currency') reads the currency from the row and ->storedAsMinorUnits() reads cents. The Quotes list uses MoneyColumn.

Note: Try it

Compare the four amounts below with what is saved (in brackets). Switch the language at the top to see German or Japanese digits.

$1,234.50
€1,234.50
¥1,235
$1,234.50