Page 1 of 1

PostPosted: Fri Feb 23, 2007 5:47 am
by Karloidd
Hi Steve, hi guys,
first of all thank you very much for this wonderful piece of software.

My problem: in a new record form sometimes i need to overwrite the default value for several fields with an arbitrary content.
Let's say I have a table 'customers' with fields defined as

[field1]
Default = ""

[field2]
Default = ""

Under some circumstances I need something like this delegate class:

class tables_customers {
function block__before_new_record_form(){
if (*something happens*) {
the_value_of_field_customer_field1 = "abc";
the_value_of_field_customer_field2 = "xyz";
}
}


then show the form as usual, letting the user to change those values before saving the new record.

I can't figure out how to set those field values.

Thank you in advance for any suggestions.
Regards, Carlo

PostPosted: Fri Feb 23, 2007 12:20 pm
by shannah

OK.. you can do this in a couple of different ways.

1. In the delegate class you can define methods of the form %fieldname%__default() which will return the default value for that field.Ê This way you can do some logic in this method to produce a different default value under different circumstances.Ê (This is the best way to do it).

2. Using javascript.Ê Add some javascript in a block like "after_new_record_form" that actually sets the default values.Ê (This isn't' as good IMHO).

-Steve


PostPosted: Fri Feb 23, 2007 1:23 pm
by Karloidd
Ok, I'll work on it. Thanks Steve

Carlo