0

I'm trying to create a multi select field that pulls in data from a matrix field. I have that part working, but am having trouble getting it to be a multi-select as well as pushing it to the freeform control panel.

Any thoughts? Thanks in advance.

<label for="product_size_chosen">Size</label><br />

<select multiple="multiple" name="product_size_chosen[]" onChange="MM_jumpMenu('parent',this,1)"> //product_size_chosen[] is freeform field//

{product_sizes_available} //This is the matrix wrap//
<option value="{product_size}">{product_size}</option> //matrix field variable//
{/product_sizes_available} //End or matrix wrap
</select>

UPDATE

I've tried using http://www.solspace.com/docs/freeform/default_fieldtypes/#multi_select unfortunately it outputs the matrix rows all as one long row and outputs all other store entries and their matrix fields on additional rows (not what's expected).

This is what it outputs

  • small large medium x-large //each sizeis a matrix fields in a single entry//
  • large x-large xx-large
  • small medium xx-large

enter image description here

Using the regular select html tags I'm able to output... (code above)

  • small
  • Medium
  • Large
  • x-large

enter image description here

This outputs correctly (1 single entry displaying all matrix rows correctly), unfortuantely I can't get the selection to be added to the database and display in freeform field. Any thoughts?

  • 1
    Did you create a field named "product_size_chosen" in the Freeform CP? Also, the field doesn't have to be a multiselect fieldtype in the Freeform CP: it can be a textarea for example. If the fieldtype is multiselect in Freeform, Freeform will expect specific values. With a textarea, you have more freedom on the data you can store in the field (and database). On the front-end, you're free to make the form field the way you want in the template (a multiselect field in this case). – Solspace Apr 3 '14 at 13:48
  • You mention "small", "medium", "large", etc. Are those CSS classes? Maybe the issue is a CSS issue? I would also look at your page's HTML output in a browser to see how your Matrix output is rendering. – Solspace Apr 3 '14 at 13:50
  • WOW... That solved the problem I converted the Freeform field from multiselect to text area and called in the matrix fields the traditional way with {exp:channel:entries} and everything just worked. Thank you for your help. It's very much appreciated. – Mark Dodgson Apr 3 '14 at 14:45
1

Given your code all you should need to do is add the select attribute multiple.

<select multiple="multiple" name="product_size_chosen[]" onChange="MM_jumpMenu('parent',this,1)"> //product_size_chosen[] is freeform field//
{product_sizes_available} //This is the matrix wrap//
<option value="{product_size}">{product_size}</option> //matrix field variable//
{/product_sizes_available} //End or matrix wrap
</select>
| improve this answer | |
  • Thank you for the reply. That actually got me one step closer. I can now select multiple items that are coming in from the matrix field. Sadly, it won't submit to the database. Everything else on the page is submitting when I remove the multiselect code. Any thoughts on why this might not go through? The variables seem to be correct and I'm not making it required. Again... Thanks for the response. – Mark Dodgson Apr 1 '14 at 14:34
  • Go the link below and see if you can output the code from the default Freeform code to see what you need to name the field. You also might have to select that field as a multi select field type instead of a text/input or text area... I'm just guessing because i can't see you code or system settings. solspace.com/docs/freeform/default_fieldtypes/#multi_select – mattsidjohn Apr 1 '14 at 17:30
  • Thanks again... I've updated the information above to offer more context. Really struggling to find the issue. – Mark Dodgson Apr 1 '14 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.