Page 1 of 1

[SOLVED] How to pass variable values to FormBuilder from a URL ?

Posted: Thu Feb 14, 2008 3:25 am
by applejack
Hi

I am trying to find out how to pass variable values to a FormBuilder form from a URL. In Perl it would just be something like
link?var1=value1&var2=value2  etc etc Ideally I would like to pass it to a drop down selection box so that a specific option within it is selected depending upon the value passed to it, but passing values to hidden fields should be fine for now.

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Thu Feb 14, 2008 7:46 am
by alby
applejack wrote: I am trying to find out how to pass variable values to a FormBuilder form from a URL.
Check in FormBuilder for pass variable to field and pass $smarty.get.your_variable

Alby

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Thu Feb 14, 2008 12:59 pm
by applejack
Hi Alby

Thanks for for getting back to me. I already did check in the help menu of Form Builder and what there is there I either didn't understand i.e. passing default values to forms or didn't answer what I need i.e. passing values from a URL. I also searched every reference to FormBuilder in the Forum but couldn't find an answer.

I would be very very grateful if you could explain this more fully and also pass $smarty.get.your_variable with a simple example.

This is crucial to me as passing data to pages and forms is half of what websites I do are about and which I have been doing using Perl for years.

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Thu Feb 14, 2008 2:44 pm
by alby
applejack wrote: Thanks for for getting back to me. I already did check in the help menu of Form Builder and what there is there I either didn't understand i.e. passing default values to forms or didn't answer what I need i.e. passing values from a URL. I also searched every reference to FormBuilder in the Forum but couldn't find an answer.
Have you search in Forum for:
pass variable "to FormBuilder"

Alby

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Thu Feb 14, 2008 4:18 pm
by applejack
Hi Alby

I found this http://forum.cmsmadesimple.org/index.ph ... 554.0.html which looks like it might do the trick, I shall have to see how it works when I get the chance to try it. Thanks for your help as always.

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Thu Feb 14, 2008 4:44 pm
by calguy1000

Code: Select all

{cms_module module='formbuilder' form='my_form' value_myField=$smarty.get.myvariable}

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Thu Feb 14, 2008 6:49 pm
by applejack
Hi Calguy

Thanks that worked apart from if the field has an underscore in it. What is the syntax to deal with such field names i.e. Your_Name as I have tried ever combination which I can think of i.e. below the Fruit part works but value_Your_Name does not.

{cms_module module='FormBuilder' form='contact_us' value_Fruit=$smarty.get.test value_Your_Name=$smarty.get.myname}

passing it as

index.php?page=contact&test=apple+orange&myname=peter

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Thu Feb 14, 2008 10:24 pm
by applejack
Ok I managed to sort it out using value_fldNUMBER

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Fri Feb 15, 2008 11:23 am
by lollipop27
Hi applejack,

i'm having about the same problem since my field names have a space in between (like 'Desired language')...
applejack wrote: Ok I managed to sort it out using value_fldNUMBER
What exactly do you mean by this? can I call the field by something else than value_MyFieldName??

Thanx.

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Fri Feb 15, 2008 1:35 pm
by applejack
Hi Lollipop

In the overall configuration settings for Form Builder here is an option which says Show Field IDs so have that checked. Then in the Main view where you create the form fields you can see each fields id number. That is the number to use i.e. value_fld39. I know it is a bit confusing as the other references in Form Builder to the fields as numbers have an underscore after fld and before the number.

If you work out how to have a drop down selection box pre selected by passing a value to it please let me know.

Also I would like to be able to change the destination email address by passing a value to it. I have done this by using the option *Email to User-Supplied Email Address passing a value to it which is a key for an email address (so as to hide the email addresses) and then in the call to form builder doing a replace of the key by the actual email address. This works for multiple keys and email addresses. The only problem is that if there is no key sent to Form Builder, when submitting the form Form Builder doesn't revert to the default destination address and the submission fails. I have not worked out if there is a way to overcome this yet. (If you see this dev's please note). E.G.

{cms_module module='FormBuilder' form='contact_us' value_Company=$smarty.get.test value_fld39=$smarty.get.testing value_Useremail=$smarty.get.useremail|replace:'key1':'my@emailaddress.co.uk'|replace:'key2':'another@emailaddress.co.uk'|replace:'key3':'mail@emailaddress.co.uk'}

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Fri Feb 15, 2008 2:13 pm
by lollipop27
Well I have a dropdownbox (.... etc, right?) preselected, I just pass the value on....

Check your code generated from the formbuilder - it uses valus in the option tag



AAA


BBB



You gotta pass on '2' not 'BBB' to preselect 'BBB'

Re: How to pass variable values to FormBuilder from a URL ?

Posted: Fri Feb 15, 2008 4:10 pm
by applejack
Hi Lollipop

Yes I tried this yesterday using a number and didn't work but just tried again and it did. Probably a typo somewhere.