Hi, sales@luxsci.com,
You can loop through the fields in the $form object and pull out the label/values for that field from the $entry object. Below is an example that loops through the $form object, checks to see if the field is a complex one like name or address, and gets the label and value. That information can be passed on to the third party however you want.
function send_entry($entry, $form)
{
//only do this for a certain form (id 53 for example)
if ($form["id"] == 53)
{
foreach($form["fields"] as &$field)
{
//see if this is a multi-field, like name or address
if (is_array($field["inputs"]))
{
//loop through inputs
foreach($field["inputs"] as &$input)
{
$label = $input["label"];
//get value from entry object; change the id to a string
$value = $entry[strval($input["id"])];
}
}
else
{
$label = $field["label"];
//get value from entry object
$value = $entry[$field["id"]];
}
}
}
}
In the example above, when looping through the fields, you can also use the code below which will combine the data for the complex fields like name into one value
//get the values for the field, will be an array if a complex field like name or address
$raw_value = RGFormsModel::get_lead_field_value($entry, $field);
//combines the data for complex fields, for example name will have the first and last combined into one value
$value = GFCommon::get_lead_field_display($field, $raw_value, $entry["currency"], true, "text");
Let me know if you have questions.
Posted 13 years ago on Wednesday February 22, 2012 |
Permalink