PDA

View Full Version : With MVC, how to format a field?



el_chief
9 Jan 2012, 8:44 PM
I have a numberfield for interest rate

the float value on the model is 0.05, representing 5%

how do i show "5" on the numberfield instead of 0.05?

also, how to save it on the model as 0.05?

preferably, using loadRecord() and getRecord(), without the controller having to do much.

Thanks!

findajit
9 Jan 2012, 9:36 PM
numberfield supports only 0-9 and decimal. It does not support %

You shall be able to use the textfield with the appropriate VType (including the mask if it is supposed to be editable) to show 5% and then you can process the value and convert it from 0.05 to 5% before loading it in the form and convert 5% back to 0.05 before saving it to a model.