I'm trying to pre-populate a form with a customer's details. However, I'm struggling with the format for the first and last name option. As far as formidable is concerned it is one field. Looking at both the $values and the $fields I can't see where to put it in. I've tried the below with no success.
function form_populate( $values, $field ) {
// Add candidate details to telephone screening form
if( $field->form_id ==2 ) {
if( !empty( $_GET['account'] ) &&!empty( $guest = get_guest( $_GET['account'] ) ) ) {
if( $field->id =='6' ) {
$values['original_default']['first'] = $guest['first'];
$values['original_default']['last'] = $guest['last'];
}
if( $field->id =='7' ) {
$values['value'] = $guest['email'];
}
if( $field->id =='8' ) {
$values['value'] = $guest['company'];
}
}
}
return $values;
}
add_filter( 'frm_setup_new_fields_vars', 'form_populate', 10, 2 );
Hi Tom,
Victor was teaching you how to fish and I'll give you a fish .
I created a form with the name field and use a hook to inspect the properties of $values. Here's what I found:
print_r of $values is Array ( [id] => 418 [default_value] => [name] => Name [description] => [options] => [required] => 0 [field_key] => ovveg [field_order] => 2 [form_id] => 47 [value] => Array ( [first] => Rob [last] => LeVine )
print_r of $values['value'] is Array ( [first] => Rob [last] => LeVine )
so $values['value']['first'] is 'Rob' and $values['value']['last'] is 'LeVine'
Thanks for that, I swear I'd tried that first, but maybe not! I've solved it using a shortcode for now. [guest attr='first']
Please login or Register to submit your answer