WebsiteBaker Community Forum

WebsiteBaker Support (2.10.x) => Modules => Topic started by: astricia on October 04, 2018, 08:45:59 AM

Title: Automatically add content to a field in Miniform ...?
Post by: astricia 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
Title: Re: Automatically add content to a field in Miniform ...?
Post by: dbs 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.
Title: Re: Automatically add content to a field in Miniform ...?
Post by: Ruud 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>
Title: Re: Automatically add content to a field in Miniform ...?
Post by: astricia 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?
Title: Re: Automatically add content to a field in Miniform ...?
Post by: Ruud 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.
Title: Re: Automatically add content to a field in Miniform ...?
Post by: astricia on October 05, 2018, 09:51:58 AM
Perfect - thanks! :-)