How to see symbol of € in Fields

Hi, in fields that have Amount, how can i see the value with decimal and symbol ?

Example
150,00 €

thanks!

1 Like

Hi Ivan,

for Table and Label you can use Formatter https://doc.cuba-platform.com/manual-6.2/gui_formatter.html. For editable Fields it is not supported, but you can add label with a currency symbol to the right of a Field manually.

Hi,

a possible solution would be to use a masked text field. But it will require the user to always fill the pre defined number of digits.

@Yuriy, since i had the same problem some time: is this possible when the field is used (as default via scaffolding) within a fieldGroup? If not would it be possible to think about an addition where after the edit field another label for something like a currency symbol or a help icon or something else can be placed within the fieldGroup definition?

Bye,
Mario

We are planning to add special type of text field - CurrencyField in one of the next minor releases, probably in 6.4.

For now you can add a label with a currency symbol for TextField inside of FieldGroup manually using custom field:

Custom field in screen XML:


<fieldGroup id="fieldGroup"
            datasource="productDs">
    <column width="250px">
        <field id="title"/>
        <field id="price" custom="true"/>
    </column>
</fieldGroup>

Java controller:


public class ProductEdit extends AbstractEditor<Product> {
    @Inject
    private FieldGroup fieldGroup;
    @Inject
    private ComponentsFactory componentsFactory;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        fieldGroup.addCustomField("price", (datasource, propertyId) -> {
            HBoxLayout hBox = componentsFactory.createComponent(HBoxLayout.class);
            hBox.setSpacing(true);
            hBox.setWidth("100%");

            TextField textField = componentsFactory.createComponent(TextField.class);
            textField.setDatasource(datasource, propertyId);

            hBox.add(textField);
            hBox.expand(textField);

            Label currencyLabel = componentsFactory.createComponent(Label.class);
            currencyLabel.setAlignment(Alignment.MIDDLE_CENTER);
            currencyLabel.setStyleName("h2");
            currencyLabel.setValue("$");
            hBox.add(currencyLabel);

            return hBox;
        });
    }
}

Any update on the CurrencyField?

Hi,

at the moment implementation is scheduled to 6.5 release.

It’s done now. But the way it is implemented is sadly of no use for us, as the currency is not static, it’s part of the model and can change.

This use case is one among others that we would like to be implemented : see this thread

If your currency is set from data, just set it to UI component programmatically and do not use @CurrencyValue annotation. Use CurrencyField.setCurrency()

Sure, but it does not fit our model where currency is an editable attribute like any other.