Populate fields in new record form

A place for users and developers of the Xataface to discuss and receive support.

Postby Karloidd » Fri Feb 23, 2007 5:47 am

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
Karloidd
 
Posts: 2
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Fri Feb 23, 2007 12:20 pm

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

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Karloidd » Fri Feb 23, 2007 1:23 pm

Ok, I'll work on it. Thanks Steve

Carlo
Karloidd
 
Posts: 2
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved