Formated value on DataObject cause error (value is changed)

6 views
Skip to first unread message

Agus Suhartono

unread,
Dec 16, 2013, 11:25:42 PM12/16/13
to openbiz-cubi
Hi

I have value from **numeric operation**, and when i passing it to fields array and save use BizDataObj::insertRecord(), the saved value is changed,

i trace it, and found this case 

$this->m_BizRecord->setInputRecord($recArr);
      ==> $realVal = BizSystem::typeManager()->formattedStringToValue($bizField->m_Type, $bizField->m_Format, $value);


so, my numeric value *regarded as* formated value, so the value changed.

I think this concept is not good
formated value is UI domain, data domain must use original/raw value

my advice :

save data from UI to database :

- user input is formated
- element internally convert formated value to original/raw value
- all data that passing to DataObject must original value.
- Data Object save data

display data from database to UI :

- reatrive data from database as original/raw value
- original value pass to element
- element internally convert original value to formated value.
- display to UI

Thanks

Agus Suhartono

Rocky Swen

unread,
Dec 18, 2013, 12:59:19 AM12/18/13
to openbi...@googlegroups.com

i believe openbiz form uses the same logic you suggested.
in the code, the formattedStringToValue method is to covert ui string to a data value.

--
You received this message because you are subscribed to the Google Groups "Openbiz Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openbiz-cubi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Agus Suhartono

unread,
Dec 18, 2013, 9:27:54 PM12/18/13
to openbiz-cubi
Rocky, 
value that return by BizDataObj is always string type and formated, because BizDataObj use BizField::getValue()

agus suhartono

Agus Suhartono

unread,
Dec 19, 2013, 2:35:19 AM12/19/13
to openbiz-cubi
the math calculation will caused error when use number format Float or Int

so, please don't use format on DataObject

i trace, the TypeManager use on BizField and DataObject only, 

when save data from form, 
Openbiz use BizRecord::setInputRecord on BizDataObject::updateRecord, BizDataObject::insertRecord and BizDataObject::deleteRecord, before save or delete data.
BizRecord::setInputRecord call BizSystem::typeManager()->formattedStringToValue()

when fetch data from BizDataObject, 
Openbiz use BizField::getValue() to call BizSystem::typeManager()->valueToFormattedString()


Regards 

Agus Suhartono
Reply all
Reply to author
Forward
0 new messages