for a price input form, I need a field that is automatically updated when another is changed, i.e. when a price of a product is entered in field 1, the net price (excluding VAT) is automatically displayed in the second.
From the docs, I learned that form pre- and postprocessing on a per-field base is not implemented (as is done in commercial products that cost a lot of $), but can be done manually with Ajax/Javascript.
So I was thinking about using the after_action_edit method for the first shot, so that the field with the net price is automatically corrected before the record is written to the database.
This is what I've come up with so far:
- Code: Select all
<?
class tables_LocalProducts
{
function after_action_edit()
{
$app =& Dataface_Application::getInstance();
$record =& $app->getRecord();
$VAT=$record->val('VAT');
$SRP=$record->val('SRP');
$Price=$record->val('Price');
$SRP_net=($SRP*100/(100+$VAT);
$Price_net=($SRP*100/(100+$VAT);
$record->setValue('Price_net',$Price_net);
$record->setValue('SRP_net',$SRP_net);
}
But this doesn't do anything - the Price_net and SRP_net fields are never touched.
I know the class is defined correctly since my __import__csv is working well.
What am I doing wrong? Is there a FAQ or HOWTO I missed?
Thanks+Regards
Bernd