Summer Sale! All accounts are 50% off this week.

roelof's avatar

money input field

Hello,

Can I have a input field which looks like this

€ and then the input field with on Thousand a . and and a . for the cents.

Roelof

0 likes
8 replies
roelof's avatar

Thanks, I say somewhere a page on the net a page where a array was used to make a number field working with decimals. But I cannot find it.

roelof's avatar

Thanks,

I have read that and I want to implement that way.

But I do not have a idea how I can take care that a user enters a decimal and I convert it to a integer before storing into the database.

I know I can multiply it by 100 but how to do that on the store method.

xingfucoder's avatar

Hi @roelof, try using the following jQuery plugin:

https://github.com/RobinHerbots/jquery.inputmask

With this plugin you can force the user to enter the value of currency as you want , later the in example, you can get the Input::get('currency') from the request to a Command or simply request the value in the Controller method and make the calculation to maintain or store it on the DB.

1 like
bashy's avatar

Enter it into the database as a decimal(10,2) or however many decimal places you want your amount to be.

Create a helper that does something like this

// May need to set this somewhere unless you have it set
setlocale(LC_MONETARY, 'en_GB.UTF-8');

// This is where you convert decimal to amount like £1,337.00
return money_format('%n', $currency);
1 like

Please or to participate in this conversation.