FormBuilder + Products: Multiselect field from Products

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
curlypinky
Forum Members
Forum Members
Posts: 109
Joined: Thu Sep 04, 2008 3:49 am

FormBuilder + Products: Multiselect field from Products

Post by curlypinky »

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)

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>
Create a Summary Template named "FB_list":

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}
In FormBuilder form:
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
Last edited by curlypinky on Sat Jun 05, 2010 12:03 am, edited 1 time in total.
Post Reply

Return to “Tips and Tricks”