I use a lot of number fields in my application. It is hard to read large numbers at a glance without some type of indicator, e.g. compare 1345600 to 1,345,600. The grocery crud number filter prevents commas from being entered into the field.
Is there some way to allow commas to be entered in the number field but stripped before the item is saved? I've poked around but can't figure out where GroceryCrud prevents anything but numbers from being entered.
Ideally the flow would be something like this:
Read number field from database
Automatically populate with commas
Automatically adjust commas if field is edited
On save, strip commas and then submit


Can I have number fields with commas?
Started by HumbleMonk, Jan 01 2013 05:02 PM
fields commas number
2 replies to this topic
#1
Posted 01 January 2013 - 05:02 PM
#2
Posted 02 January 2013 - 08:12 AM
Put this on your controller
$crud->callback_column('price',array($this,'format_num'));
and add this function :
function format_num($value, $row){
return number_format($value, 0);
}
$crud->callback_column('price',array($this,'format_num'));
and add this function :
function format_num($value, $row){
return number_format($value, 0);
}

#3
Posted 03 January 2013 - 11:08 PM
Thank you for the answer.
That results in a formatted field, like I want, however it is not editable. I need this field to be editable.
That results in a formatted field, like I want, however it is not editable. I need this field to be editable.
Also tagged with one or more of these keywords: fields, commas, number
Support →
Grocery CRUD Enterprise →
Join fields from different tables within one fieldStarted by Manuel, 26 Nov 2020 ![]() |
|
![]() |
||
Support →
Grocery CRUD Enterprise →
How can I hide/show a field during edit based on the selected value of the drop-down?Started by larasmith, 17 Aug 2017 ![]() |
|
![]() |
||
Support →
I have a question →
How to set fields after upload with file informationStarted by Gonzalo Morel, 05 May 2016 ![]() |
|
![]() |
||
Support →
I have a question →
change width of field in the grocerycrud tableStarted by ahmed122, 06 Dec 2014 ![]() |
|
![]() |
||
Support →
Bugs / Issues →
name colomn is numberStarted by Lord_Zeus, 18 Nov 2014 ![]() |
|
![]() |
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users