FormBuilder + Products: Multiselect field from Products
Posted: Fri May 14, 2010 8:44 am
I needed to create a form that would allow visitors to send feedback to the site owner about their experience and optionally select the items they had rented. CGfeedback would not work for this purpose as they want testimonials on one page rather than tied to a specific product.
I created a formbuilder form and tied Products to it using the "-Module Interface Field" type. I needed the products organized by hierarchy in a single multiselect field (checkboxes would have been overwhelming on the page). I have tested this with FormBrowser and email disposition and it works like I need it to - sends a comma separated list of the product names.
My steps:
In Products:
Create a Hierarchy Report Template named "FB_hier_list":
(corrected for Products 2.8.2)
Create a Summary Template named "FB_list":
In FormBuilder form:
Create -Module Interface Field
Under "add your tag"
The result is a multiselect menu in your form that lists each hierarchy name and the items that belong to it, something like so:
---HIERARCHY 1---
Product 1
Product 2
Product 3
---HIERARCHY 2---
Product 4
Product 5
Hopefully this is helpful to others!
Alane
I created a formbuilder form and tied Products to it using the "-Module Interface Field" type. I needed the products organized by hierarchy in a single multiselect field (checkboxes would have been overwhelming on the page). I have tested this with FormBrowser and email disposition and it works like I need it to - sends a comma separated list of the product names.
My steps:
In Products:
Create a Hierarchy Report Template named "FB_hier_list":
(corrected for Products 2.8.2)
Code: Select all
<label>Products<br />(Select multiple items by holding Ctrl while selecting)</label>
<select name="{$FBid}[]" id="{$FBid}" multiple="multiple" size="8">
{assign var='prodmod' value=$mod}
{if !isset($hdepth)}{assign var='hdepth' value='0'}{/if}
{foreach from=$hierdata key='key' item='item'}
<option>--- {$item.node.name|upper} ---</option>
{Products hierarchy=$item.node.name|cat:'*' summarytemplate="FB_list"}
{/foreach}
</select>
Code: Select all
{foreach from=$items item=entry}
{assign var=MData value=''}
{assign var=Cd value=''}
{foreach from=$FBvalue item=MData}
{assign var=MData value='::'|explode:$MData}
{if $MData[1]==$entry->id}
{assign var=Cd value=' selected="selected"'}
{/if}
{/foreach}
<option value="{$entry->product_name|escape}::{$entry->id}" {$Cd}>{$entry->product_name}</option>
{/foreach}
Create -Module Interface Field
Under "add your tag"
Code: Select all
{Products action="hierarchy" hierarchytemplate="FB_hier_list"}
The result is a multiselect menu in your form that lists each hierarchy name and the items that belong to it, something like so:
---HIERARCHY 1---
Product 1
Product 2
Product 3
---HIERARCHY 2---
Product 4
Product 5
Hopefully this is helpful to others!
Alane