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.

Dynamically add Image Upload QTY to Hidden Field?

  1. Hi,

    I have a form that allows users to choose how many photos to upload.
    First they have to choose from the drop-down 'How many photos?", which then displays the correct amount of Image Upload fields.
    I have setup a hidden field which I want to store the result in. How do I dynamically get the answer? How many photo's are my user's uploading?

    Thanks

    Posted 13 years ago on Monday October 3, 2011 | Permalink
  2. Can't you go by what they select in the drop down? Or is the problem they might not actually upload that number of images and you want a 100% accurate number?

    Posted 13 years ago on Monday October 3, 2011 | Permalink
  3. Hi Carl,

    I do need 100% accuracy as I need the form to tell another plugin the figure for deducting 'credits' from a user's account.

    Is there a way to get the figure (the value) to dynamically appear in a hidden field at the end of the form for the 'credit's plugin to get that figure?

    Huw

    Posted 13 years ago on Tuesday October 4, 2011 | Permalink
  4. You could only do this by adding a hidden field to your form and then using custom PHP and available hooks to populate that hidden field after the form is submitted.

    You'd have to write custom code to do this, you'd have to check each upload field to make sure there was a value and then populate the value of the hidden field based on the upload fields that were used.

    You would use the gform_pre_submission hook to do this so it happens before the entry data is stored and notifications are sent. This hook is documented here:

    http://www.gravityhelp.com/documentation/page/Gform_pre_submission

    Posted 13 years ago on Tuesday October 4, 2011 | Permalink