WordPress.org

Support

Support » Plugins and Hacks » Populating Multi Picklists through checkboxes

Populating Multi Picklists through checkboxes

  • valerio_cas
    Member

    @valerio_cas

    I thought I’d share my solution for this in case it helps anybody, even though it’s a bit hacky. If someone has a better solution, please let me know.

    The plugin maps GF multiselect to SalesForce Picklist (Multi-Select), but my client wanted to use checkboxes.

    1. Add the code to convert commas to semicolons, as in the FAQ section.
    2. Add a select box to your form, with the same values as your checkboxes.
    3. Hide this with CSS
    4. Add this code to populate the select box values with the checkbox values on submit.
      In this case, my checkbox field ID was 6, and my hidden select box ID was 10:
    add_action("gform_pre_submission", "mysite_pre_submission_handler");
    function mysite_pre_submission_handler($form){
    
    	$temp = array();
    
        if ($_POST['input_6_1'])
    		$temp[] = $_POST['input_6_1'];
    
    	if ($_POST['input_6_2'])
    		$temp[] = $_POST['input_6_2'];
    
    	$_POST['input_10'] = $temp;
    }

    https://wordpress.org/plugins/gravity-forms-salesforce/

Viewing 1 replies (of 1 total)
  • Jason
    Participant

    @ijas0n

    Thanks valerio_cas, this is exactly what I’m looking for.

    However, I can’t seem to get it to work.

    I’ve got my checkbox fields which is “input_1_12” and then I have my hidden multiselect field which is “input_1_50”.

    I tried emulating your code with my fields, but I’m not sure where you got your input_6_2 from. Anyway, this is my code below:

    add_action("gform_pre_submission", "mysite_pre_submission_handler");
    function mysite_pre_submission_handler($form){
    
        $temp = array();
    
        if ($_POST['input_1_12'])
            $temp[] = $_POST['input_1_12'];
    
        if ($_POST['input_1_13'])
            $temp[] = $_POST['input_1_13'];
    
        $_POST['input_50'] = $temp;
    }

    I’m trying to just pass on the checkbox fields to the multi-select. Let me know.

Viewing 1 replies (of 1 total)
  • The topic ‘Populating Multi Picklists through checkboxes’ is closed to new replies.