Using hidden fields

SKirsch 13 Nov, 2011
In CF 4 I have established 3 hidden fields :
paiement_total
code
date

In Custom Code I defined these as :
<?php
$code = date("MdHi");
$paiement_total = $actes+$paiement;
$date = date("dmy");
?>


actes and paiement are defined visible fields.

In my email response the template gives me :
<tr> <td> Hidden #21
      </td>
  <td> {date}
      </td>
</tr>
<tr> <td> Hidden #19
      </td>
  <td> {code}
      </td>
</tr>
<tr> <td> Hidden #15
      </td>
  <td> {paiement_total}
      </td>
</tr>


However these field do not populate and stay blank.
Can you help me. The Custom Code is placed before the email action.
Thank you
GreyHead 14 Nov, 2011
Hi Skirsch,

I think that the Custom Code needs to be
<?php
$form->data['code'] = date("MdHi");
$form->data['paiement_total'] = $actes+$paiement;
$form->data['date'] = date("dmy");
?>

Bob
SKirsch 14 Nov, 2011
Thanks,

Lines 1 and 3 work fine, however line 2 is returning a zero instead of the sum. When I call {actes} or{paiement} separately I get their value but the sum is not working. Any idea ?
GreyHead 14 Nov, 2011
Hi Skirsh,

How have you defined $actes and $paiment ?

Bob
SKirsch 14 Nov, 2011
Hi

actes and paiements were define as Field Names in radio boxes. $paiement has a choice of 4 values assigned and $actes is one value assigned. When I call up these fields individually in Thank You or Email actions their values show up. It is when I try to have the sum + that I only get 0.

$form->data['paiement_total'] = $paiement + $actes;

If I change the expression to include only $paiement (or only $actes) {paiement_total} returns nothing. If I place a number value I get the number. And as I said above {paiement} or {actes} gives its value.

I do not know where the php scripts are written on the interior of Joomla. So I am lost as how to resolve this remaining issue and get my payment form on line.

Thank you
GreyHead 15 Nov, 2011
Hi SKirsch,

If they are form values you need to get them from the results
<?php
$paiement = $form->data['paiement'];
$actes= $form->data['actes'];
$form->data['paiement_total'] = $paiement + $actes; 
?>
or
<?php
$form->data['paiement_total'] = $form->data['paiement'] + $form->data['actes']; 
?>


Bob
SKirsch 17 Nov, 2011
Thank you for your efficiency and your promptness. That work perfectly. I am now getting the hang on the syntax for the php in Chronoforms. Greatly designed program. I shall be able to do many things with it.
This topic is locked and no more replies can be posted.