Author Topic: Automatically add content to a field in Miniform ...?  (Read 5068 times)

Offline astricia

  • Posts: 783
  • Gender: Female
    • netSchmiede24
Automatically add content to a field in Miniform ...?
« on: October 04, 2018, 08:45:59 AM »
Is there a way to automatically add content to a certain variable in a Miniform template?

I am working on a website for an industrial company with the entire product catalogue on the website. The client would like a contact form on each individual product page to request more information. I was thinking of realizing this with Miniform - but I would like to automatically add the Name of the Product and/or the Product number to the form, so that my client will know about which product they need more information.

Anybody can put me in the right direction, so that I don't have to set up 200 different contact forms... ?

Thanks,
Astrid

Offline dbs

  • Betatester
  • **
  • Posts: 8803
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Automatically add content to a field in Miniform ...?
« Reply #1 on: October 04, 2018, 09:15:56 AM »
Hi, had done it before some weeks, but ... i forgot how.
With OFA, item-name in $_SESSION, hidden input field in miniform template and there a droplet what read the $_SESSION['item-name'].

I think Ruud will have a better way.

Offline Ruud

  • Posts: 3669
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Automatically add content to a field in Miniform ...?
« Reply #2 on: October 04, 2018, 10:31:24 AM »
https://miniform.dev4me.com/module-help/tips-and-tricks/ (Field data in links)

The formnames wihout mf_ or mf_r_ can be used as parameter in the url.
Just create a link to your formpage like yoursite.com/pages/formpage.php?fieldname=value&otherfieldname=othervalue

Using OFA or Bakery you could use the output template like:
Code: [Select]
<a href="https://yoursite.com/pages/formpage.php?product=[TITLE]&sku=[FIELD_1]">Order</a>

Offline astricia

  • Posts: 783
  • Gender: Female
    • netSchmiede24
Re: Automatically add content to a field in Miniform ...?
« Reply #3 on: October 04, 2018, 01:25:16 PM »
Ok, I can get the link to have a ?product=[TITLE] in it (I have built the product catalogue with OFA of course....), but it doesn't show up in the contact form.

What is the exact call for the field in the form itself? I have
Code: [Select]
<div class="full">
<label for="product"><span>Anfrage für </span>
<input class="{PRODUCT_ERROR}" type="text" id="product" name="product" value="{PRODUCT}" />
</label>
</div>

And does it matter that the Title of the OFA Item contains spaces?

Offline Ruud

  • Posts: 3669
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Automatically add content to a field in Miniform ...?
« Reply #4 on: October 04, 2018, 01:52:26 PM »
In miniform all form fields start with mf_ or mf_r_

So name="product" should be name="mf_product" or name="mf_r_product". (no changes to the rest)
That way your link should work.

Offline astricia

  • Posts: 783
  • Gender: Female
    • netSchmiede24
Re: Automatically add content to a field in Miniform ...?
« Reply #5 on: October 05, 2018, 09:51:58 AM »
Perfect - thanks! :-)