HEEx
<div class="w-72">
<ConnieUI.Forms.money_value placeholder="Amount" field={@field} />
</div>
Variant matrix
Every combination of one or two attributes, side by side.
Controls
Set by the example
field class
Docs
An amount of money held in one field with its currency, as JSON, the one
value a SmartTag stores, in `money/1`'s box.
It is `money/1` for a place with a single value to write to, and it is built
for a contract body the way `identity_number/1` is: the markup lives in a
`<template>` the element copies into place, because a `<div>` inside a
paragraph makes the HTML parser close it, and `white-space` is reset because
a contract paragraph is `break-spaces`. `picker` keeps the currency list out
of a body that is redrawn on every keystroke, and `input_name` mirrors the
value into the contract editor's hidden input for the tag.
The amount is stored as typed. Which separator is the decimal point is the
host's to read when it takes the value, since a person in Copenhagen writes
4.500,50 and one in London 4,500.50. The browser only refuses what no reading
could make an amount of.
Nothing is stored until an amount is typed, so a required tag with only a
currency picked is still unanswered.
| Attribute | Type | Default | Description |
|---|---|---|---|
| No data found. | |||
| field * | {:struct, Phoenix.HTML.FormField} |
The stored value, currency and amount together.
|
|
| input_name | :string | nil |
A named input elsewhere on the page to mirror the stored value into.
|
| default_currency | :string | nil |
The currency picked while nothing is stored, e.g. the one the issuer pays in.
|
| placeholder | :string | nil |
|
| invalid | :boolean | nil |
Overrides the field's own errors, for a caller with no changeset behind the field.
|
| invalid_message | :string | "Enter an amount, like 4500 or 4.500,50" |
Why a typed amount cannot be submitted.
|
| disabled | :boolean | false |
Unusable: the currency as text before the amount, and nothing to submit.
|
| readonly | :boolean | false |
Read, not filled in: drawn as `disabled` is, but at full contrast, reachable
by the keyboard and announced as read-only with its currency. For a value
somebody is shown, such as one they are agreeing to.
|
| picker | :string | nil |
The id of a `currency_picker/1` rendered once elsewhere on the page. Without
one the currency list is rendered inline.
|
| size | :string | "sm" |
sm | md
|
| class | :any | "block" |
Replaces the default, rather than adding to it.
|
| rest | :global |
|
|