Change input format

1
0
-1

Hi,
My client asked if it were possible to change the format for some types of inputs.

For example, they need a "money format" : "12345.0" gives "12 345,00 €"
They also need a "percentage format" : "12" gives "12%"

Do I need to create a CustomWidget for that ?
Thank you for your answers

3 answers

1
+2
-1

Yes you will need a custom widget for that, or just send the data to the screen as a pre-prepared string.

Either way you should be cognoscente of the locale of the user and display in their standard format.

Trouble is numbers, as you've found out, mean nothing without it's specification. take the number 12...12 months, 12 hours (1/2 a day), 12 Monkeys...etc.

Your choice of how to do it...my preferred way as I use multi-locale is to do it in script and send strings of data...

also have a look at this for working stuff...

http://www.decorplanit.com/plugin/

regards
Seán

PS: if this answers your question, please mark it as Resolved.

1
0
-1

Hi Quentin,

My need is to change the formatting on the widget, not on another input.
The link Sean gave is what I need, but I don't think the same thing exists for Angular (and I don't want to import JQuery dependencies :P )

But thank you anyway :)

Comments

Submitted by Quentin Choulet on Wed, 12/23/2015 - 16:04

That's exactly what filters do.

Here is an example with the currency filter:
show.php?id=96795
And the result :
show.php?id=96796

Submitted by p.clainchard on Wed, 12/23/2015 - 16:12

Yes, but this is a filter, not a directive :)
So in your example you cannot edit this input.

I would like to have the same thing for a widget in which I can type ^^

1
0
-1

Hi,

If you need to do some basic formatting, take advantage of AngularJS style filters. The basic syntax is: myVariable | aFilter and is supported in Bonita7 inputs. AngularJS provides some basic filters to format currencies, numbers, json, etc ... Full list here.

If the basic filters does not suit your needs you can create your own filters.

Notifications