Page 1 of 1

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

Posted: Fri Dec 16, 2011 12:54 pm
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'}

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

Posted: Sat Dec 17, 2011 2:06 pm
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

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

Posted: Sat Dec 17, 2011 2:14 pm
by Jonny
Many thanks for your prompt response to my PM and the working example.

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

Posted: Sat Dec 17, 2011 2:20 pm
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}