• Resolved itsmir

    (@itsmir)


    Hello,

    I have a form integrated with HubSpot and all is working as required apart from one thing.

    The form has a dropdown list of names, each having an email address as it’s value. When the form is completed the data in the notification emails and on the submissions page show the name selected from this field – great! However in HubSpot the imported data displays the value (email address) not the name which we don’t want. I understand this maybe expected behaviour.

    Is there a way to prepopulate a (hidden) text field with the label of the selection made from the dropdown field? If there was we could use this to import into HubSpot and my client would be happy again 🙂

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @itsmir

    By default all submissions relies on value, not label. I pinged our SLS Team to check if this will be possible. hank you for your patience while we look into this further.

    Kind Regards,
    Kris

    Hi again @itsmir

    add_filter( 'forminator_prepared_data', 'wpmudev_add_hidden_field_val', 10, 2 );
    function wpmudev_add_hidden_field_val( $prepared_data, $module_object ){
    	if ( $module_object->id != 6 ) {
    		return $prepared_data;
    	}
    
    	if ( ! empty( $prepared_data['hidden-1'] ) ) {
    		$prepared_data['hidden-1'] = forminator_replace_form_data( $prepared_data['hidden-1'], $module_object, null, true );
    	}
    
    	return $prepared_data;
    }

    In the code 6 should be changed to your form ID, hidden-1  to your hidden field’s ID and in hidden field you should select custom value and in the value use the macro of the select field for example {select-1}

    You can find your form ID in page source where form is located, or edit your form in WP Dashboard and URL of that page edit will contain that ID.

    Kind Regards,
    Kris

    Thread Starter itsmir

    (@itsmir)

    That’s done the trick!

    Many thanks Kris, it’s much appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Prepopulate text field from dropdown selection’ is closed to new replies.