• Resolved pstidsen

    (@pstidsen)


    Hello there,

    I have an array with X (approximately 1-10) elements. For each element, I need to create an e-mail field where users can enter their e-mail addresses. Upon submission, an e-mail should be triggered based on the specific element in the array.

    I’ve been brainstorming different approaches, and I’d appreciate some guidance regarding the best way to implement this functionality through Forminator. Here are a couple of ideas I’ve considered:

    1. Looping through the array to generate individual forms: My initial thought was to iterate through the array and generate a separate form for each element. This way, users can submit a form to trigger the corresponding e-mail. If they need to trigger additional e-mails, they can submit another form. Is it possible to generate simple Forminator?forms using a for loop or a similar mechanism?
    2. Single form with multiple e-mail fields: Alternatively, I’ve considered creating a single form that includes multiple e-mail fields, each corresponding to an element in the array. Users would fill in the relevant e-mail field, and the corresponding e-mail would be triggered. Is it possible to generate and manage multiple e-mail fields within a single Forminator?form based on the elements in the array?

    All e-mails triggered should be the same template – just different content based on the correspongdig element in the array.

    The reason why I want to use your plugin is that I want the features about validation and spam protection.

    I would greatly appreciate any insights or suggestions you might have regarding the best way to approach this problem. Thank you in advance for your time and assistance!

    Best regards,
    Peter

Viewing 2 replies - 16 through 17 (of 17 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @pstidsen

    Thanks for response!

    Based on your recent explanation, I think I misunderstood you initially.

    What you are asking for wouldn’t be possible out of the box if it has to be “automated”. Let me break that down.

    1. Is it possible to show the same form multiple times on the same page?

    Yes, it’s possible, you simply include that form on the page as many times as you need.

    2. Is it possible to automatically populate a hidden field with some data?

    Yes, it is possible; simplest way is to use code provided by my colleague above, though the one I share earlier is also based on similar principle.

    3. Is it possible to show multiple forms on the same page and at the same time automatically populate hidden field with different data for each form?

    Not really. The codes share are PHP codes and they work on server level so they “don’t know” what’s currently on page or to what part of the page they refer; they operate based on the form and field ID only – so with same form those would be the same in every form.

    To achieve this you would actually need some way to get the form actually rendered in a custom way entirely, replacing field IDs also. That doesn’t seem doable at the moment and even if it is, it would require a huge and complex custom code. That would, I’m afraid, be out of the scope.

    —-

    There may possibly be an alternative to to this using JS but under three conditions:

    a) instead of hidden field a regular input field would need to be used (though could be hidden with CSS – not with visibility rules!)

    b) and the ID that needs to be automatically put in that field would need to be already on the page in some easily (and “distinctly”) accessible code block (like, for example, a DIV with a specific class).

    c) and both form and that element should be inside some “unique” wrapper (like a DIV with unique ID or class)

    So this way a JS could be fired e.g. upon form load, could find the “parent” block for that form and inside that block find a specific element from which it would take ID and then put it as a value to that form.

    This could possibly work but then again – I’m afraid that’s a code for a very specific case scenario and, speaking form experience, it may quickly turn out to be way more complex than it sounds. We can only provide basic/simple custom code and this kind of development seems out of scope of our support.

    Kind regards,
    Adam

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @pstidsen ,

    We haven’t heard from you for some time now, so it looks like you don’t require our further assistance.

    Feel free to re-open this topic if needed.

    Kind regards
    Kasia

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Forms based on dynamic array’ is closed to new replies.