Page 1 of 1

Docs for calcuated fields? HELP!

PostPosted: Sun Dec 12, 2010 4:40 am
by Chris
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?

Re: Docs for calcuated fields? HELP!

PostPosted: Mon Dec 13, 2010 10:58 pm
by shannah
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');

Re: Docs for calcuated fields? HELP!

PostPosted: Tue Dec 14, 2010 1:19 am
by Chris
Wow, that shows something about the code quality when you can guess at a function name and get that close.
Very good system.