Forums

combine multiple form fields before db save.

cyberrock 21 Nov, 2016
Hi Bob,
Quick query. I have a form html table with with all parts of an address in separate fields and need to combine them all prior to db save.

This is what i have in DB save conditions
<?php
$PickupAddress = $form->data['street_number'];
$PickupAddress .= $form->data['route'];
$PickupAddress .= $form->data['locality'];
$PickupAddress .= $form->data['administrative_area_level_1'];
$form->data['PickupAddress '] = $PickupAddress ;
?>

Thanks again

Ben
GreyHead 21 Nov, 2016
Hi Ben,

I'm not sure if that will work in the Conditions box - that is intended to identify the record that you want to update. Please try the code in a Custom Code action before the DB Save action.

The PHP is OK but will leave no spaces between the parts: something like this might work better:
<?php
$PickupAddress   = array();
$PickupAddress[] = $form->data['street_number'];
$PickupAddress[] = $form->data['route'];
$PickupAddress[] = $form->data['locality'];
$PickupAddress[] = $form->data['administrative_area_level_1'];
$form->data['PickupAddress '] = implode(', ', $PickupAddress);
?>

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