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.

Create new fields?

  1. Hi, is it possible to create our own fields?

    I'd like to tweak the address field that is included with Gravity Forms, changing some of the defaults. We have our own list of states/provinces and countries that we need to use.

    Thanks.

    Posted 13 years ago on Wednesday June 30, 2010 | Permalink
  2. Currently it is not possible, however we do plan on adding some hooks down the road that would allow you to do this. It's on our to do list. But it probably won't be in the next release.

    Posted 13 years ago on Wednesday June 30, 2010 | Permalink
  3. Ok, thanks.

    Posted 13 years ago on Thursday July 1, 2010 | Permalink
  4. ...but you can update the content of these fields before the form is rendered use the Gravity Forms "gform_pre_render_*formid*" hook. Here is a sample of its usage pulled from the Gravity Forms change log:

    add_filter("gform_pre_render_17", test_render); //Adds a filter to form id 17. It is also possible to use gform_pre_render to filter every form
            function test_render($form){
                $form["fields"][1]["isRequired"] = true; //Dynamically marks a field (id=1) as required
                return $form;
            }

    I've used this function several times when needing to update the values available for a particular field in the form. You could similarly replace the default list of states/provinces with your own using this hook.

    Posted 13 years ago on Friday July 2, 2010 | Permalink
  5. Very interesting, thanks.

    Posted 13 years ago on Thursday July 8, 2010 | Permalink
  6. Thanks again for this. I found some other sample code which seems to do the trick for separate <select> fields:

    http://forum.gravityhelp.com/topic/drop-down-value-different-than-content-text

    But, I can't get this to work for the "Country" which is part of an 'address field.'

    The id is something like 9.6.

    Seems as though the countries are hard-coded, in a way.

    Any ideas?

    (Of course, Carl did say this was not possible...)

    Thanks-
    Bill

    Posted 13 years ago on Thursday July 8, 2010 | Permalink