?
avatar chnnst
chnnst
23 Feb 2021

Is your feature request related to a problem? Please describe.

Not possible to Add Currency Field

https://www.php.net/manual/en/numberformatter.formatcurrency.php

Describe the solution you'd like

formatCurrency(1234567.891234567890000, "EUR")."\n"; ?>

The above example will output:

1.234.567,89 €

Additional context

Simple to add field but very useful for j4

avatar chnnst chnnst - open - 23 Feb 2021
avatar joomla-cms-bot joomla-cms-bot - change - 23 Feb 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 23 Feb 2021
avatar brianteeman
brianteeman - comment - 23 Feb 2021

It is more complex than that as the rules for the position of the currency symbol and the character used for the decimal and thousand separators are different in different countries and different languages.

There is also no need for a new field as it is already possible to create a custom field with a prefix or suffix.

avatar infograf768
infograf768 - comment - 23 Feb 2021

There is also no need for a new field as it is already possible to create a custom field with a prefix or suffix.

The code needed is indeed much more complex.
Example:

<?php
	$fmt = new NumberFormatter('fr_FR', NumberFormatter::CURRENCY);
	$fmt->setTextAttribute(NumberFormatter::CURRENCY_CODE, 'CAD');
	$fmt->setPattern( str_replace('¤#',"¤\xC2\xA0#", $fmt->getPattern() ) );
	echo $fmt->formatCurrency(1234567.891234567890000, 'CAD');
?>

will display in French format a Canadian Dollar value.

Therefore, one has to check the language in use and the currency chosen for the display, both being defined as variables.
The currencies proposed should be, I guess, proposed as a list.

This needs some code and I am not sure what you mean by creating a custom field with prefix or suffix.
Looks to me we have to create an entirely new field plugin.

Could you explain further?

avatar brianteeman
brianteeman - comment - 23 Feb 2021

Therefore, one has to check the language in use and the currency chosen for the display, both being defined as variables.

And the locale

This needs some code and I am not sure what you mean by creating a custom field with prefix or suffix.

Just use a number field and either the prefix or suffix param to display the currency symbol

Looks to me we have to create an entirely new field plugin.

I see no need for this

avatar chnnst
chnnst - comment - 23 Feb 2021

Where can we find prefix and suffix param in number field?

avatar infograf768
infograf768 - comment - 23 Feb 2021

Just use a number field and either the prefix or suffix param to display the currency symbol

Lost in translation. I was thinking Custom Field plugin with specific code. One cannot use the default core Number field (which is not a plugin) with the necessary code for the formatting. The currency symbol is also added by the code above.

Forget it.

avatar infograf768
infograf768 - comment - 23 Feb 2021

This does not mean that we should create this plugin for core btw.

avatar brianteeman
brianteeman - comment - 23 Feb 2021

Where can we find prefix and suffix param in number field?

image

avatar chnnst
chnnst - comment - 23 Feb 2021

prefix and suffix param in number field exists only in j4 but in j3 it doesn't exists, is it correct?

avatar ssnobben
ssnobben - comment - 26 Feb 2021

prefix and suffix param in number field exists only in j4 but in j3 it doesn't exists, is it correct?

You can test yourself by installing Joomla 3 and Joomla 4. These learning Joomla questions should be better and only asked in Joomlas forum https://forum.joomla.org/ so create a user profile there and ask these questions similar like these there.

If you didnt know Github is for core Joomla developers that focus on developing Joomla not learning how Joomla works or administration of Joomla as siteowen etc

See all Joomla docs where you can learn a lot about how Joomla works. https://docs.joomla.org/Main_Page and there is a lot of tutorials & videos example https://www.youtube.com/channel/UCEmHl8-zBTXbTfqMGLVLYuw and if you want to customise Joomla yourself you can test also Joomla Component Builder JCB https://www.joomlacomponentbuilder.com/ with many learning videos https://www.youtube.com/playlist?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE so there you have your solutions!

avatar chnnst
chnnst - comment - 26 Feb 2021

I tested and see no prefix and suffix param in number field in j3 thats why brian was asked to explain. @ssnoben if you is developer please tell where is this code ? In what file ? What line?

@ssnobben please don't spam with old tutorial and not maintained doc links.

avatar rdeutz rdeutz - change - 26 Feb 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-02-26 13:12:09
Closed_By rdeutz
avatar rdeutz rdeutz - close - 26 Feb 2021

Add a Comment

Login with GitHub to post a comment