Docs for calcuated fields? HELP!

Archived from the Xataface Users forum.

Chris — Sun Dec 12, 2010 4:40 am

I’ve spent hours looking for any documentation on using calculated fields, and I cannot find any! Could someone please point me in the right direction, or if there isn’t give a brief primer (I won’t need much, just how to get started).

I was expecting something like this.

field.ini

Code: Select all
[CALCFIELD] widget:type = calc widget:name = mycalcfield

atable.php

Code: Select all
`class tables_mytable …

function field_CALCFIELD(&$record) {
return ‘the calculated value’;
}`

Where did I go wrong?


shannah — Mon Dec 13, 2010 10:58 pm

Your second attempt is close:

Code: Select all
function field__calcfield($record){     return 'calculated value'; }

Then you can use the field programmatically:

Code: Select all
$record->val('calcfield');

Chris — Tue Dec 14, 2010 1:19 am

Wow, that shows something about the code quality when you can guess at a function name and get that close.
Very good system.