PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

drop down value on form 1 determines which form 2 is displayed

  1. First I would like to have a drop down value on my first form direct which form is loaded second.
    Second, I am trying to load the second form within the same area on the same page rather than a confirmation or redirect, replacing the area previously taken by form 1. As if it was a page 2 of the form. My second form(s) accept query string to populate hidden fields.

    Alternately could I change the short code form number dynamically based on a dropdown value on form 1?

    Any suggestions?

    Posted 6 years ago on Sunday May 26, 2013 | Permalink
  2. Trying to clarify. I have a dropdown for US states, I need each state selected on the first form to redirect to a different url on my site which contains the proper second form. Any ideas?

    Posted 6 years ago on Wednesday May 29, 2013 | Permalink
  3. Here is what I am trying to put together:

    Form 1 has two dropdown fields, one of which is which state do you live in?
    I would like to set the dropdown for state on form 1 to redirect to a specific url based on the state the user selects.

    There are 50 pages containing a different form 2, a page for each state with a unique form. The page slug for these corresponding pages are each state's 2 letter abbreviation.

    Need to target dropdown field to validate based on css class assigned.

    Target dropdown contains US states.
    Each state triggers a gorm_confirmation to redirect to site_url(CUSTOM) ELSE a static redirect url if no match.

    Dynamically build site_url(CUSTOM) where (CUSTOM) = /2 letter state code (the value selected in the state dropdown field)

    Match US state selected in dropdown on form 1 to the site_url(CUSTOM) and redirect.
    basically matching the dropdown field value to the page slug for redirect.

    To target this validation and confirmation I would like to add a css class to the field and thought the code below (found in the forum here for vin number validation) would allow.

    1 - Tie our validation function to the 'gform_validation' hook
    
    add_filter('gform_validation', 'state-redirect');
    function state_redirect($validation_result) {
    
        // 2 - Get the form object from the validation result
        $form = $validation_result["form"];
    
        // 3 - Get the current page being validated
        $current_page = rgpost('gform_source_page_number_' . $form['id']) ? rgpost('gform_source_page_number_' . $form['id']) : 1;
    
        // 4 - Loop through the form fields
        foreach($form['fields'] as &$field){
    
            // 5 - If the field does not have our designated CSS class, skip it
            if(strpos($field['cssClass'], 'validate-vin') === false)
                continue;
    
            // 6 - Get the field's page number
            $field_page = $field['pageNumber'];
    
            // 7 - Check if the field is hidden by GF conditional logic
            $is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
    
            // 8 - If the field is not on the current page OR if the field is hidden, skip it
            if($field_page != $current_page || $is_hidden)
                continue;
    
            // 9 - Get the submitted value from the $_POST
            $field_value = rgpost("input_{$field['id']}");
    
            // 10 - Make a call to your validation function to validate the value
            $is_valid = is_state($field_value);

    Any help would be greatly appreciated!

    Posted 6 years ago on Wednesday May 29, 2013 | Permalink