This topic is locked

insert as default a value

3/2/2011 7:30:03 AM
PHPRunner General questions
C
caese author

Hello. I want to insert as default a value:

In before record added
//num_contrato is a numeric field - I want to see as default the greatest val + 1
$sql="select max(num_contrato) as numero from contratos";

$consulta = mysql_fetch_array(mysql_query($sql));

$numero = ($consulta['num_contrato']+1);

$values["num_contrato"]=$numero;
//Nothing appear in the field. What i make wrong?
Thanks in advance. Sorry about my english.

Sergey Kornilov admin 3/2/2011

BeforeAdd event is executed after form is submitted - that's why you don't see anything in this field.
You can add this code to BeforeProcess event and save result to session variable. Then use this session variable as a 'Default value' of this field.

C
caese author 3/2/2011



BeforeAdd event is executed after form is submitted - that's why you don't see anything in this field.
You can add this code to BeforeProcess event and save result to session variable. Then use this session variable as a 'Default value' of this field.


Tank you for your response.

Could you give me a clearer example of how I do it?

Sergey Kornilov admin 3/2/2011

Please clarify what exactly not clear.