Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Giacomo Lanza 8 posts 77 karma points
    Aug 22, 2017 @ 09:55
    Giacomo Lanza

    No code generate by hidden field


    I checked that no HTML code is generated by the hidden field: enter image description here I expect to see something like:

    <input type="hidden" value="..." name="..." id="...">

    I would like to set an hidden field via Javascript and use it as a field on the email template So the question is. How can I use the Formulate hidden?


  • Nicholas Westby 2054 posts 7100 karma points c-trib
    Aug 22, 2017 @ 15:49
    Nicholas Westby

    We can definitely talk about ways to make that happen (I have three solutions in mind). However, I'm curious about your use case. For everything I've built Formulate for so far, I've been able to avoid using hidden input field elements.

    When I need to use a static bit of text, I use the "Text Constant" field type. When I need to generate a field value (e.g., when combining multiple fields into a single field), I use the "Hidden" field type and set the value on the server side. When I need to get something from the client side, I have so far only needed to set a cookie (that I then transfer to hidden field values on the server side).

    Could you explain a bit about your use case so that I can be sure to offer better guidance?

  • Giacomo Lanza 8 posts 77 karma points
    Aug 23, 2017 @ 07:47
    Giacomo Lanza

    Hi Nicholas,

    thank you for your concern. I developed a simple website that has a page with a list of products ( . Every product has a link to a detail page ( whose content is dynamic and is based on the product properties. That detail page has a form, created using Formulate, so the customer can use that form to ask for further detail. I would like to send the product Id (or better, the product name) as a field of the email just to know the name of the product for which the customer has requested information. I need to generate a hidden field with the product name as a value:

    <input type="hidden" value="[product name]" name="..." id="...">

    This is my use case. Do you think that is possible to do with Formulate?


  • Nicholas Westby 2054 posts 7100 karma points c-trib
    Aug 23, 2017 @ 15:22
    Nicholas Westby

    It sounds like what you want is a hidden field, but you need not set it on the client side. You can set it on the server side with a Formulate submitting event. You can subscribe to it like this (e.g., from an ApplicationStarting event in a class that inherits from ApplicationEventHandler):

    formulate.api.Submissions.Submitting += FormSubmitting;

    Then you can set the value of the hidden field in that event handler:

    /// <summary>
    /// Handles the form submitting event.
    /// </summary>
    private static void FormSubmitting(FormSubmissionContext context)
        // Set hidden field value in here.

    Does that sound workable to you?

Please Sign in or register to post replies

Write your reply to: