default radio value from form data

Set a default radio button value from form data in ChronoForms.

Overview

The issue occurs when the passed variable name differs from the form input name, preventing automatic value assignment.
Use the form's On Load event to add a Custom Code action that maps the passed variable to the correct form input name.

Answered
Ni NickOg 08 Aug, 2014
Hi all,

I can' see a solution to this in the forum. I must be missing something.😲 πŸ™„

I want to set the default value for the radio control to a value passed to that form. The attached may explain the problem more easily.

The value $form->data['paidBy'] is in the form and I have added <?php $form->data['paidBy'];?> and variants on that echo and so on all to no avail.

What have I missed?
[attachment=0]4Chrono00.png[/attachment]
[attachment=1]4Chrono01.png[/attachment]
Gr GreyHead 09 Aug, 2014
Answer
Hi Nick,

You need to set the value of the entry in the $form->data[''] array. If the passed variable and the form input have the same name it will work automatically, in your case the names are different so you have to add some code. In the form On Load event add Custom Code action with code like this:
<?php
$form->data['inprdoPayBy'] = $form->data['paidBy'];
?>

Bob
This topic is locked and no more replies can be posted.