[solved] Formbuilder - setting selected="selected" from link

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Jonny
Forum Members
Forum Members
Posts: 77
Joined: Sun Sep 24, 2006 10:49 am

[solved] Formbuilder - setting selected="selected" from link

Post by Jonny »

I'm planning a form which includes a select element (pulldown) for choosing from a list of items.

The items all have their own pages, and I'd like to provide a link on each of those pages to the form that will set the pulldown to the relevant item. i.e. applying selected="selected" to a specific option.

The variable for the pulldown is {$fld_10}, and there are 15 options in the pulldown, so how could I link to a page containing the following form tag to set the pulldown to option 5?

{cms_module module='FormBuilder' form='events'}
Last edited by Jonny on Sat Dec 17, 2011 2:46 pm, edited 1 time in total.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: Formbuilder - setting selected="selected" from link

Post by applejack »

Code: Select all

{if $smarty.get.office} {cms_module module='FormBuilder' form='contact_us' value_fld15=$smarty.get.office} {else} {cms_module module='FormBuilder' form='contact_us'} {/if} 
Linked from

Code: Select all

/contact-form/?office=2
Example

http://www.goringberry.co.uk/contact/of ... harrogate/

Click the contact us link
Jonny
Forum Members
Forum Members
Posts: 77
Joined: Sun Sep 24, 2006 10:49 am

Re: Formbuilder - setting selected="selected" from link

Post by Jonny »

Many thanks for your prompt response to my PM and the working example.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: Formbuilder - setting selected="selected" from link

Post by applejack »

Your welcome.

You don't have to pass a number just whatever is the value of the option you want selected. If it contains spaces then you will need to use |replace if using get instead of post. You will also need I seem to remember assign it to a variable as you cannot do the replace in the form builder smarty tag. i.e.

Code: Select all


?office=this_is_my_value

{if $smarty.get.office}
{assign var=tmp value=$smarty.get.office|replace:'_':' '}
{cms_module module='FormBuilder' form='contact_us' value_fld15=$tmp}
{else}
{cms_module module='FormBuilder' form='contact_us'}
{/if} 

Post Reply

Return to “Modules/Add-Ons”