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.

saving custom complex fields, RGFormsModel::prepare_value...

  1. G'day, I'm adding a custom complex field to my plugin (for recurring donations) and can't seem to work out how to save a concatenated value for the field. The custom field has multiple parts and I want to concatenate them and save as a formatted string.

    RGFormsModel::save_input() only saves fields with a value, sensibly, but how do I give it a value to save? I figured that RGFormsModel::prepare_value() would be the place to hook into for that, but there's no filter hook called from it.

    Can you please advise what I need to do here?

    Posted 12 years ago on Wednesday September 19, 2012 | Permalink
  2. Hi, webaware,

    The easiest way to do what you want is to have a hidden field on your form and populate that with the values you want to save. You need to:

    1. Do NOT name the input tags in your custom field using the Gravity Forms naming convention of input_FIELD_ID since you do not want this data saved.
    2. Name your hidden field using the Gravity Forms naming convention of input_FIELD_ID. Naming your field this way will ensure that Gravity Forms will use that field's value when saving your custom field.
    3. Populate the hidden field using the "gform_pre_submission" hook (http://www.gravityhelp.com/documentation/page/Gform_pre_submission).

    Posted 12 years ago on Wednesday September 19, 2012 | Permalink
  3. G'day Dana,

    So for my complex field, I should:

    * rename all my fields to use non-GF names
    * add a hidden field to my complex field that uses GF naming convention and pre-populate it on submission

    OK, I can do that. Will give it a shot. Of course, it would be easier if RGFormsModel::prepare_value() had a filter hook allowing plugins to add custom field types :)

    cheers,
    Ross

    Posted 12 years ago on Wednesday September 19, 2012 | Permalink
  4. Beauty, all working now, thanks.

    cheers,
    Ross

    Posted 12 years ago on Thursday September 20, 2012 | Permalink
  5. Thanks for the update Ross.

    Posted 12 years ago on Thursday September 20, 2012 | Permalink

This topic has been resolved and has been closed to new replies.