1

I'm using LWC, but I can't set custom currency in the lightning-input, using type number or currency.

I also try to use lightning-input-field of type currency, but I found in documentation:

Displays an input field for entering monetary data. The user’s Salesforce locale determines the currency symbol and separator characters used to format the number. Specifying a different locale is currently not supported for currency.

We have users with, for example, local with USD but they can create Quotes in different currencies.

We need code something like that:

    <lightning-input type="number"
                 label="Price"
                 value="12345"
                 formatter="currency"
                 currencyIsoCode="EUR">
    </lightning-input>

Last line: currencyIsoCode="EUR" it's what I need to set.

Thank you.

2 Answers 2

2

Unfortunately, the same problem exists in aura, but the workaround is to use ui:inputcurrency . LWC does not have ui-inputcurrency equivalent yet and thus you have to build it yourself.

You can use SLDS classes to give lightning look, you can refer my sample:

<template>

<div class="slds-form-element">
  <label class="slds-form-element__label" for="text-input-id-1" id="fixed-text-label">Price</label>
  <div class="slds-form-element__control slds-input-has-fixed-addon">
    <span class="slds-form-element__addon" id="fixed-text-addon-pre">£</span>
    <input type="number" id="text-input-id-1" placeholder="2000" aria-labelledby="fixed-text-label fixed-text-addon-pre fixed-text-addon-post" class="slds-input" />
    <span class="slds-form-element__addon" id="fixed-text-addon-post">euro</span>
  </div>
</div>
</template>

Playground Link : https://developer.salesforce.com/docs/component-library/tools/playground/jee6KjW0-/1/edit

3
  • Please note that the ui: components will be being deprecated as of the winter release if I correctly understood information given during the Salesforce Partner Forum London developer track sessions.
    – Phil W
    Jun 3, 2019 at 16:20
  • Thanks for the heads up @PhilW Jun 3, 2019 at 16:22
  • Thank you @PranayJaiswal I had think about this solution, but I wanted to check if another one exists.I think I'll have to implement that. Jun 4, 2019 at 8:12
-1

Lightning-input now supports FORMATTER attribute to allow CURRENCY and others like (decimal, percent, percent-fixed)

https://developer.salesforce.com/docs/component-library/bundle/lightning-input/specification

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .