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.

Add fields to form object

  1. paddelboot
    Member

    Possible? I.e. with gform_pre_render hook?

    Posted 12 years ago on Monday July 23, 2012 | Permalink
  2. Not possible using gform_pre_render. Can you explain what you're trying to do? Maybe there is another way.

    Posted 12 years ago on Monday July 23, 2012 | Permalink
  3. paddelboot
    Member

    It's about dynamically generated forms, or whatever you want to call it.
    Simply display field A only if var B has a value of C. If var B is an array with N elements, then display N fields.

    The built-in conditional logic doesn't help me much here, as far as I understand it.

    Paddelboot

    Posted 12 years ago on Tuesday July 24, 2012 | Permalink
  4. Conditional logic will help you display form fields based on matching conditions as you describe. However, the elements need to already be present in the form you created in the form builder, so they can be shown conditionally.

    If you can provide a more detailed explanation of what you want to do, we can help point you to the correct information.

    Posted 12 years ago on Tuesday July 24, 2012 | Permalink
  5. paddelboot
    Member

    Let's say you want to build a shopping cart form in which the customer can set the amount and/or other details about every item he wants to purchase.

    You cannot know in advance how many items there will be in the shopping basket when you call the form.

    Displaying the same form several times on the same page also seems to be problematic.

    Therefore, you'd need to dynamically add fields to the form. Since, in the background, every form field is just an array with an amount of keys and values, this shouldn't be impossible.

    I hope this is understandable now.

    Paddelboot

    Posted 12 years ago on Tuesday July 31, 2012 | Permalink
  6. paddelboot
    Member

    So far, I have only found cforms II to be able to do this.

    http://www.deliciousdays.com/cforms-plugin/

    Check under API/Creating dynamic forms.

    It's interesting that this feature seems not to be demanded by many users.

    Paddelboot

    Posted 12 years ago on Tuesday July 31, 2012 | Permalink
  7. I'll move this to feature requests so we don't forget about it. Thanks.

    Posted 12 years ago on Tuesday July 31, 2012 | Permalink