Rounding of fields in CMSB
2 posts by 2 authors in: Forums > CMS Builder
Last Post: June 10, 2011 (RSS)
By rjbathgate - June 9, 2011
Hey,
I have numeric values posted to my database, and I want to
a) keep the value posted in it's full format
b) display the value in CMSB rounded to 2.
I can easily display the rounded value on front end using
But I was wondering if there was an easy way to set a field within a viewer/section editor to this same formatting.
Obviously I could format the value BEFORE posting it to the database, but I would prefer not to do that if there is an easy way to format the section editor.
Thanks
Rob
I have numeric values posted to my database, and I want to
a) keep the value posted in it's full format
b) display the value in CMSB rounded to 2.
I can easily display the rounded value on front end using
number_format($tableRecord['field'], 2);
But I was wondering if there was an easy way to set a field within a viewer/section editor to this same formatting.
Obviously I could format the value BEFORE posting it to the database, but I would prefer not to do that if there is an easy way to format the section editor.
Thanks
Rob
Re: [rjbathgate] Rounding of fields in CMSB
By Jason - June 10, 2011
Hi Rob,
You can create a custom plugin that would format these values for you. The issue with storing the full format of the number and then displaying the formatted number is that if you're displaying this formatted number in the edit page and the record is saved, the full format number will be overwritten.
Since you want to maintain the full format of this number in the database, the best option would probably be to create a plugin that will format this number in the list view and viewer pages, but not in the editor section.
If you'd like us to look into creating that plugin for you, please send an email to consulting@interactivetools.com and we can go over some options.
Hope this helps
You can create a custom plugin that would format these values for you. The issue with storing the full format of the number and then displaying the formatted number is that if you're displaying this formatted number in the edit page and the record is saved, the full format number will be overwritten.
Since you want to maintain the full format of this number in the database, the best option would probably be to create a plugin that will format this number in the list view and viewer pages, but not in the editor section.
If you'd like us to look into creating that plugin for you, please send an email to consulting@interactivetools.com and we can go over some options.
Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/