Page 1 of 1

Pass an email recipient variable in formbuilder tag

Posted: Sun Jul 23, 2017 6:08 pm
by Mich-adg
Hi,
i'm looking for a tip to pass an email address in the formbuilder tag.
I have one form, and it must show on multiple page, but must have another recipient according to the viewed page (so i can add a variable in the smarty field of each page, but how to pass this variable to Formbuilder tag ?).
Thanks for any idea... !

Re: Pass an email recipient variable in formbuilder tag

Posted: Sun Jul 23, 2017 9:48 pm
by Jos
I think you can use the fieldtype *Email Results Based on Pulldown
You could hide the field with css and set the value with javascript according to the page.

Re: Pass an email recipient variable in formbuilder tag

Posted: Sun Jul 23, 2017 10:03 pm
by Jo Morg
Or, and assuming you did set an alias to the field suggested by Jos, you can replace the field with

Code: Select all

<input type="hidden" name="{$actionid}{$<fieldalias>->input_id}" value=""/>
where <fieldalias> should be replaced by the alias of the field. I tend to replace all the field auto handling of the default FB template by my own HTML fields as long as I keep the name="{$actionid}{$<fieldalias>->input_id}" rule for every single field I have defined previously on FB. Also need to keep in mind that some fields handling arrays of values will surely need [] appended to the name attribute. This means that you can handle virtually any type of form with FB, be it simple or complex.

Re: Pass an email recipient variable in formbuilder tag

Posted: Mon Jul 24, 2017 8:41 am
by Mich-adg
Thanks for the tips !!
Jo : how do you replace the field? In the form template?
If i use the javascript method, will the email address be "visible" for spam bots?

Re: Pass an email recipient variable in formbuilder tag

Posted: Mon Jul 24, 2017 11:27 am
by Jos
Mich-adg wrote: If i use the javascript method, will the email address be "visible" for spam bots?
No because you define item/value pairs in the fielddefinition, and of course the item should be something else than the emailadres.

Re: Pass an email recipient variable in formbuilder tag

Posted: Mon Jul 24, 2017 11:32 am
by Jo Morg
Mich-adg wrote:Jo : how do you replace the field? In the form template?
Yes. As I said:
Jo Morg wrote:I tend to replace all the field auto handling of the default FB template by my own HTML fields
But for that you'll either trap the correct field on the foreach loop or replace all the fields which is what I do. However to be able to call the fields by alias you'll have to set them on all fields.
Mich-adg wrote:If i use the javascript method, will the email address be "visible" for spam bots?
As Jos just replied, and is also valid with the hidden field approach...
Mich-adg wrote:I have one form, and it must show on multiple page, but must have another recipient according to the viewed page (so i can add a variable in the smarty field of each page, but how to pass this variable to Formbuilder tag ?).
In this case you don't need javascript...

Code: Select all

<input type="hidden" name="{$actionid}{$<fieldalias>->input_id}" value="{$MySmartyVar}"/>

Re: Pass an email recipient variable in formbuilder tag

Posted: Tue Jul 25, 2017 7:30 am
by Mich-adg
Thanks so much !