Page 1 of 1

Change a database value before display

Posted: Fri Jan 03, 2014 10:52 am
by agnar
Basically, I need to change the value of a database field before it is displayed in an edit form.

For, examle, I might set a date to the current date (say, as a last modification date)

I can set a default value for a new record easilly, but can't figure out how to do it on an existing record.

Agnar

Re: Change a database value before display

Posted: Fri Jan 03, 2014 4:35 pm
by massiws
Agnar, you could use nuLoadThis() function in Custom Code > Javascript.
For example:

Code: Select all

if ( $("#your_field").val() === '' ) {
  $("#your_field").val('default value');
}
If the field isn't on the form you can:
  • use AJAX call to get the value from DB;
  • load the value field in a hidden field on the form.
If you change the value via Javascript, remember to update the field in DB using uDB() function.

Hope this helps,
Max