This topic is locked

Hidden fields

9/1/2010 8:07:16 AM
PHPRunner General questions
S
sanchez author

Hello,
I want to add hidden fields and searched the help and there I found this code:
function BeforeAdd(&$values)
{
// Parameters: // $values - Array object. // Each field on the Add form represented as 'Field name'-'Field value' pair
$values["Field1"]="default value for Field1";
$values["UpdatedDate"]=now();
$values["UpdatedBy"]=$_SESSION["UserID"];
return true;
// return true if you like to proceed with adding new record // return false in other case
}

My question is, where must I put this code? I've tried to click the INSERT PHP SNIPPET CODE and paste is there but that does not work.

A
ann 9/1/2010

Sanchez,
proceed to the Events tab, open Add page: Before record added event and add the code:

$values["Field1"]="default value for Field1";

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

$values["UpdatedBy"]=$_SESSION["UserID"];

return true;



make sure you've replaced Field1, UpdatedDate, UpdatedBy with your actual field names.

S
sanchez author 9/1/2010



Sanchez,
proceed to the Events tab, open Add page: Before record added event and add the code:

$values["Field1"]="default value for Field1";

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

$values["UpdatedBy"]=$_SESSION["UserID"];

return true;



make sure you've replaced Field1, UpdatedDate, UpdatedBy with your actual field names.


Well, this is my code:
function BeforeAdd(&$values)
{
// Parameters: // $values - Array object. // Each field on the Add form represented as 'Field name'-'Field value' pair
$values["content_objid"]="0";
$values["content_date"]=print(date("d-m-Y"));
$values["content_time"]=now();
$values["content_comments_disabled"]="0";
return true;
// return true if you like to proceed with adding new record // return false in other case
}
IT still does not work because I get the next error:
<<< Record was NOT added >>>
Field 'content_objid' doesn't have a default value
What's wrong?

Sergey Kornilov admin 9/1/2010

There might be an error in your code - the use of print() function doesn't make much sense here.
If removing print() function call doesn't help post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

S
sanchez author 9/1/2010



There might be an error in your code - the use of print() function doesn't make much sense here.
If removing print() function call doesn't help post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.


Nope, that does not change a thing. I've opened a ticket.