This topic is locked

Default Value Not Working on Edit Page

2/10/2006 12:54:35 PM
PHPRunner General questions
T
Tommy B author

I have two views to a transaction table. The first view uses a default value to include the username in a read only field on the Add screen.
On the administration table view, this field is edit as: read only. It works great and shows the username of the user who originally added the transaction.
However, the administrator view is only setup to edit each transaction to "approve" or "deny" them. I tried adding "@$_SESSION["OwnerID"]" as the default value for this read only field but it is not populating the user's username.
It seems that the default value only works on the add page and not the edit page. I could see why this would be helpful (to keeo from overwriting) existing data with a default value, but I don't want the transaction administrator to be able to enter another username other than his in this field.
Any ideas?

Sergey Kornilov admin 2/12/2006

Default values work on the ADD page only.
Could you clarify what you like Admin user to do with this field?

T
Tommy B author 2/21/2006

I created a Support Request management system for my users. They'd create a request in one table view, and through an administrative table view I'd have the ability to respond to their request and change the status from pending to closed.
My idea was to also have a date and time field that would populate when the user editted the record. This could probably be accomplished with a timestamp of some sort but I had no luck after a bit of trying.

Sergey Kornilov admin 2/22/2006

Tommy,
you can add default value on EDIT page using events. Choose Before Record Added event on the Events Tab for required table, click Add action and select Custom code. See my changes in Bold

function BeforeEdit(&$values, $where)

{

// Parameters:

// $values - Array object.

// Each field on the Edit form represented as 'Field name'-'Field value' pair

// $where - string with WHERE clause pointing to record to be edited

$values["CurrentDate"]="now()";

//** Custom code ****

// put your custom code here

return true;
// return true if you like to proceed with editing this record

// return false in other case

}



where CurrentDate is actual field name.