Skip to main content

Currency Widget Documentation

OverviewDirect link to Overview

The Currency widget provides a specialized input field for monetary values with built-in currency formatting, locale support, and validation. It automatically formats numbers according to the selected currency and locale, making it ideal for financial applications, e-commerce platforms, and any interface requiring monetary input.

Currency Widget

FeaturesDirect link to Features

  • Multiple Currency Support: Supports major international currencies
  • Locale Formatting: Automatic number formatting based on locale settings
  • Precision Control: Configurable decimal places (0-20)
  • Negative Values: Negative amounts are allowed by default and can be turned off
  • Empty Until Typed: The field starts empty, so the Required check really applies
  • Default Value: A fixed amount, or a calculated amount that follows its variables
  • Real-time Formatting: Formats input as user types
  • Validation: Built-in validation rules with custom messages
  • Responsive Design: Adapts to different screen sizes

Configuration InterfaceDirect link to Configuration Interface

Global SettingsDirect link to Global Settings

  1. Name: Enter a descriptive label for your currency field
  2. Variable/Model: Define the variable name (e.g., amount, price, total)
  3. Default Value: The amount when the page opens: see Default Value
Currency Global Settings

Default ValueDirect link to Default Value

Since version 8.6, the field is empty until the user types an amount; it used to start at 0. The variable holds null until then, so the Required check applies to a field nobody filled in, instead of accepting 0.

To start with an amount:

  • With the Default Value field: the Global card holds a Default Value field, between Variable/Model and On Change, with its fx corner and the placeholder Number or =formula. It is the field described in Input › Default Value. The builder canvas shows the value as written.
  • With Flowy: ask Flowy to set it, for example "start this amount at 1250.50" or "this amount is quantity × unit price".
  • With an action: a setModel action in On Mounted sets the variable when the page opens. It runs at every opening and overwrites an amount already saved, for example in a reopened task: to keep that amount, put the setModel inside an if action with the condition {{amount}} == null. It does not follow other variables.

Default Value accepts:

ValueExampleResult
A number, with a dot for decimals1250.5, 0, -20That amount when the page opens
A variable{{amount}} or ${amount}The value of this page variable; the field then follows it
A formula{{quantity}} * {{price}} or ={{quantity}} * {{price}}Calculated when the page opens, then again each time one of its variables changes
Anything elseabc, 12,5Ignored: the field stays empty and the page still opens

Good to know:

  • The user can overwrite the amount.
  • A comma is flagged under the field: 12,5 is not a number, and Fix in the large editor proposes 12.5.
  • The suggestions do not offer the connected user.
  • Default Value only applies if the variable does not exist yet when the page opens: an amount already saved, for example in a reopened task, is kept. A setModel action in On Mounted does not have this protection (see above).
  • When a variable of the formula changes, the new result replaces what the user typed. Disable the field when it shows a calculated total.
  • Inside a loop, {{quantity}} reads the field of the same row when quantity is a field of that loop (a row total: {{quantity}} * {{price}}). Other names read the page variables.
  • An amount is a number: the field formats it, so do not format it in the formula, and do not mix it with text (use an Input for Total {{amount}}).
  • To round to the cent and count an empty field as 0: Math.round(Number({{quantity}} || 0) * Number({{price}} || 0) * 100) / 100.

Currency ConfigurationDirect link to Currency Configuration

  1. Local: Select the locale for number formatting
    • Affects decimal separators, thousand separators
    • Determines currency symbol placement
    • Values: en-EN (default), de-DE, de-CH, en-US, en-IN, nl-NL, sv-SE, fr-FR, es-ES, pt-PT, zh-ZH, ja-JP, ar-SA, fa-IR
  2. Currency: Choose the currency type
    • Values: EUR, USD (default), GBP, MAD, BRL, INR, CNY, JPY, SAR, IRR
    • Can be set to hidden to hide the currency symbol: the field shows 1,250.50 instead of $1,250.50
  3. Allow Negative: Enable negative value input (on by default)
    • Useful for discounts, refunds, or adjustments
  4. Precision: Set decimal places
    • Range: 0-20
    • Common values: 2 for most currencies, 0 for whole numbers

Local and Currency are lists: you cannot type a variable in them, so the currency and the locale of a widget are fixed when you build the page. To offer several currencies, add one widget per currency and show the right one with a Visible condition. Flowy can also set a 3-letter ISO 4217 code that is not in the list, for example CAD.

Currency Currency Configuration

Validation RulesDirect link to Validation Rules

The currency widget supports comprehensive validation:

Built-in ValidationDirect link to Built-in Validation

  • Required Field: Mark field as mandatory. An empty field is refused; a typed 0 counts as a value
  • Type Validation: Ensures numeric input only
  • Minimum and Maximum Amount: The widget has no setting for them. Use a Custom rule (see below)

Custom Validation RulesDirect link to Custom Validation Rules

Add custom validation rules with:

  • Rule Type: Select from available validation rules
  • Value: Set the validation parameter
  • Message: Custom error message for validation failure

To limit an amount, add a Custom rule, where SF_input holds the amount:

SF_input == null || (SF_input >= 10 && SF_input <= 1000)

SF_input == null lets an empty field through: use Required to refuse it.

Good to know:

  • Min (Char) and Max (Char) are rules for a text: on this widget they refuse every amount typed, whatever its value. Do not use them here.
  • The rules are checked when the form is validated, for example by a validateForm action, and not when the user leaves the field.
Currency Validation Rules

Style ConfigurationDirect link to Style Configuration

Layout OptionsDirect link to Layout Options

  • Width: Set field width (e.g., "100%", "200px")
  • Placeholder: Hint text shown when field is empty
  • Class: CSS classes for custom styling
Currency Style Configuration

Advanced FeaturesDirect link to Advanced Features

Event HandlingDirect link to Event Handling

The On Change row of the Global section sets the action triggered when the amount changes, with its Action on field change button:

  • Access the new amount with SF_input.value
  • Useful for calculations, validations, or API calls
  • Can trigger custom actions and functions

The drawer that opens is titled On Click, as for every widget: here, it holds the action of the field change.

Currency Event Handling

Validation ScreensDirect link to Validation Screens

Configure widget behavior across different interface screens:

Screen-based SettingsDirect link to Screen-based Settings

  • Available: Show/hide widget per screen
  • Visible: Control visibility with conditions
  • Required: Make field mandatory per screen
  • Disable: Disable input per screen
Currency Screen-based Settings

Advanced ConditionsDirect link to Advanced Conditions

Use JavaScript expressions for dynamic behavior: click Advanced Setting in the Validation section, then the pencil of the rule. In this example, the field is only visible when the order total is over 100:

Currency Advanced Conditions

Usage ExamplesDirect link to Usage Examples

Basic E-commerce Price InputDirect link to Basic E-commerce Price Input

A price in US dollars, with two decimals and no negative amount:

Currency Basic E-commerce Price Input

Financial CalculatorDirect link to Financial Calculator

An investment amount limited by a Custom rule, SF_input == null || (SF_input >= 1000 && SF_input <= 1000000), with its message:

Currency Financial Calculator

Integration TipsDirect link to Integration Tips

Form IntegrationDirect link to Form Integration

  • Works seamlessly within form containers
  • Inherits form validation behavior
  • Supports form submission and reset

API IntegrationDirect link to API Integration

  • Values stored as numbers for easy API transmission
  • Format display vs. stored value handled automatically
  • Compatible with REST APIs and GraphQL

Data BindingDirect link to Data Binding

  • Two-way data binding with form models
  • Real-time updates to connected components
  • Automatic type conversion and validation

Best PracticesDirect link to Best Practices

User ExperienceDirect link to User Experience

  1. Clear Labels: Use descriptive field names
  2. Helpful Placeholders: Provide example formats
  3. Immediate Feedback: Show formatting as user types
  4. Error Messages: Clear, actionable validation messages

PerformanceDirect link to Performance

  1. Efficient Updates: Use onChange events judiciously
  2. Validation Timing: Balance real-time vs. submit validation
  3. Currency Loading: Cache currency data when possible

AccessibilityDirect link to Accessibility

  1. Keyboard Navigation: Ensure full keyboard accessibility
  2. Screen Readers: Provide appropriate ARIA labels
  3. Color Contrast: Maintain readable text contrast
  4. Focus Management: Clear focus indicators

TroubleshootingDirect link to Troubleshooting

Common IssuesDirect link to Common Issues

Currency Not Formatting

  • Check locale setting matches expected format
  • Verify currency code is supported
  • Ensure precision setting is appropriate

Validation Not Working

  • Review validation rules configuration
  • Check required field settings per screen
  • Verify custom validation expressions
  • If every amount is refused, replace the Min (Char) or Max (Char) rule with a Custom rule

Amount Empty Instead of 0

  • Since version 8.6, an untouched field is empty and its variable holds null
  • In a script or a calculation, use Number(amount || 0)
  • To start at 0, give the field the default value 0

Value Not Saving

  • Confirm variable/model name is unique
  • Check form submission configuration
  • Verify data binding is properly configured

Browser CompatibilityDirect link to Browser Compatibility

  • Modern browsers with JavaScript ES6+ support
  • Vue.js 2.x compatibility required
  • Currency formatting uses Intl.NumberFormat API

SupportDirect link to Support

For additional assistance with currency widget configuration:

  1. Check validation error messages for specific guidance
  2. Review browser console for JavaScript errors
  3. Test with different currency/locale combinations
  4. Verify integration with your specific form setup