1

I have a custom form (hardcoded, not a GF) on one page I've written myself:

<form id="tailor-select" method="POST">
    <ul>
        <li>
            <ul>
                <li>
                    <input name="input_9.1" type="checkbox" value="Cover Design" id="choice_2_9_1" tabindex="1">
                    <label for="choice_2_9_1" id="label_2_9_1">Cover Design</label>
                </li>
                <li>
                    <input name="input_9.2" type="checkbox" value="Artwork Creation" id="choice_2_9_2" tabindex="2">
                    <label for="choice_2_9_2" id="label_2_9_2">Artwork Creation/Redrawing/Relabelling <a rel="#artwork" href="javascript:void(0);">read more ></a></label>
                </li>
                <li>
                    <input name="input_9.3" type="checkbox" value="Map Creation" id="choice_2_9_3" tabindex="3">
                    <label for="choice_2_9_3" id="label_2_9_3">Map Creation</label>
                </li>
                <li>
                    <input name="input_9.4" type="checkbox" value="Indexing" id="choice_2_9_4" tabindex="4">
                    <label for="choice_2_9_4" id="label_2_9_4">Indexing <a rel="#indexing" href="javascript:void(0);">read more ></a></label>
                </li>
                <li>
                    <input name="input_9.5" type="checkbox" value="Proof Reading" id="choice_2_9_5" tabindex="5">
                    <label for="choice_2_9_5" id="label_2_9_5">Proof Reading <a rel="#proof" href="javascript:void(0);">read more ></a></label>
                </li>
                <li>
                    <input name="input_9.6" type="checkbox" value="Digital Deliverables" id="choice_2_9_6" tabindex="6">
                    <label for="choice_2_9_6" id="label_2_9_6">Digital Deliverables <a rel="#digital" href="javascript:void(0);">read more ></a></label>
                </li>
                <li>
                    <input name="input_9.7" type="checkbox" value="Author Liaison" id="choice_2_9_7" tabindex="7">
                    <label for="choice_2_9_7" id="label_2_9_7">Author Liaison <a rel="#author" href="javascript:void(0);">read more ></a></label>
                </li>
            </ul>
        </li>
        <li>
            <input type="submit" value="Ok! I'm ready to fill out the enquiry form >" class="choose">
        </li>
    </ul>
</form>

What I want to do is, if any of these check boxes are 'checked', then that data gets passed to a gravity form (ID = 2) on another page, and the corresponding checkboxes will be check already...

I get that the data needs to be POSTed and that the action on the submit needs to be the url of the page the GF form is on.

I also know that I can use hooks in my functions.php file, but reading the Gravity Forms docs, it says nothing about using a form to fill a form - well, at least none that I could see/find. Kinda like this:

function populate_fields($value, $field, $name) {
    $values = array(
         'field_one'   => 'value one',
         'field_two'   => 'value two',
         'field_three' => 'value three',
    );
    return isset($values[$name]) ? $values[$name] : $value;
}
add_filter('gform_field_value', 'populate_fields', 10, 3);

My question is, how do I get the data passed from the custom form to the Gravity Form?

I don't really know where to start I'm afraid

Thanks =/

closed as off-topic by jgraup, birgire, Sisir, bueltge, Mayeenul Islam Aug 19 '16 at 13:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2

Try this:

  1. Check the Allow field to be populated dynamically box (done).
  2. Enter a parameter name (in this example, I'll call it my_param).
  3. Add code to functions.php:

    function populate_fields( $value, $field, $name ) {
        // Use the POSTed data if it's there
        return isset( $_POST[ $name ] ) ? $_POST[ $name ] : $value;
    }
    add_filter('gform_field_value_my_param', 'populate_fields', 10, 3);
    

Note that the filter is gform_field_value_{$parameter_name}, not simply gform_field_value.

Reference

Using Dynamic Population

  • Thanks for your help. This didn't work. I'm gonna have a play around with and see if I can do it and post my code here... – Remo Web Dec 18 '15 at 12:03
  • I've updated my answer to use the $_POST data. Note that this does no sanitization or validation. – Pat J Dec 18 '15 at 16:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.