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.

web form's action, onsubmit, labels customize-able?

  1. I currently have a web form (standard php/html non-gravity form) as defined as follows:

    <form name="campus_visit" id="campusID" action="<? echo $formhandlerpath; ?>" method="POST" onsubmit="return qasVerify( true );">

    It is a form which does some Javascript processing when submitted, and if returned with no problems, the form is then submitted to the action as above (won't go into too much detail, but essentially then calls a webservice for address verification).

    Is it possible to customize a GravityForm to do the same? I would be needing to include an external javascript .js file which would do some processsing upon a click of the submit button, and if the processing is completed with no problems, I would then submit to another .php web page.

    Can we perform this in GravityForm such that we customize the button and form behaviors? If so, where would we do so? Which file?

    Also, I would be neeeding to have ability to control the id's of the labels inside the form since my external javascript files need to retrieve the values entered in these labels.

    Thanks,
    Ricky

    Posted 14 years ago on Wednesday October 13, 2010 | Permalink
  2. It may be possible, but you would lose all of the available Gravity Forms validation capabilities if you change the form action. It is also a customization so it isn't something we provide support for but we can certainly provide you with the correct hook to use.

    Here is the hook to modify the form tag, this example shows how to change the form action:

    add_filter("gform_form_tag", "form_tag", 10, 2);
    function form_tag($form_tag, $form){
    $form_tag = preg_replace("|action='(.*?)'|", "action='custom_handler.php'", $form_tag);
    return $form_tag;
    }

    You can also use a hook to change the submit button:

    add_filter("gform_form_tag", "form_tag", 10, 2);
    function form_tag($form_tag, $form){
    $form_tag = preg_replace("|action='(.*?)'|", "action='custom_handler.php'", $form_tag);
    return $form_tag;
    }

    There is no hook for changing the field id's because they are dynamic and part of the form engine.

    Posted 14 years ago on Wednesday October 13, 2010 | Permalink
  3. Thanks Carl for your response. Just wanted to make sure something...

    In your last post, you mentioned "There is no hook for changing the field id's because they are dynamic and part of the form engine."

    Let me add a bit about my goal...What I want to know is that I have an external javascript file that I would like to integrate with a WordPress Gravity form...one requirement is that my javascript file does some processing that will require me at the time of development to hardcode in my external javascript file: the ID of the gravity form, and the IDs of the labels inside the gravity form. Is this possible to get the IDs of my gravity form and hardcore them in my javascript file? Or are they dynamically generated and I cannot code them in my javascript file? Or alternatively, can I precode the IDs in my javascript, and manually specify what I want the IDs of my gravity form to be (though I think this isn't possible according to your last post about them being part of the engine dynamically).

    Please let me know, thanks.

    Posted 14 years ago on Thursday October 28, 2010 | Permalink
  4. Yes, you can get the id's of your form fields by building your form, embedding it on the page/post it is gong to be displayed on and then go to that page in your browser and either view source or inspect the HTML using a tool like FireBug and see what the id's are for the fields.

    They are dynamically generated but at the time you create the form, not every time the form is displayed.

    Posted 14 years ago on Friday October 29, 2010 | Permalink