2

I am trying to set up Freeform Pro's dynamic Select list types (Country, State, and Load from Channel Field). I would like the first option to be an empty value / label pair like:

-- Select --

For country and state I was able to insert a blank value by modifying the corresponding language files (hackish, but it could work). Or I could of course just copy and paste a regular value/label list into the Newline Delimited Textarea option.

Unfortunately, I cannot figure a way to include a blank value/label pair for the "Load from Channel Field" option. I would like to keep this dynamic so the list is automatically updated without forcing the client to remember to update the field as the channel data changes.

Has anyone been able to find a better solution for inserting an empty value/label pair for the first entry in these dynamic selects?

2 Answers 2

2

I seem to recall on a large project I worked recently that if you're using Pro to create the actual form AND you're also using the code it generates or the simple {freeform:field:my_field_name} in your template then you're limited to no real options.

If you build the template using traditional you can insert a bogus <option value="nothing">Select</option> in the code but past that you either build it manually and have blank options or use the Freeform shortcut tags and deal with the lack of "select" options unfortunately.

That was some 6+ months ago so it may have changed.

2
  • 1
    This is what I found, too. Hoping for a secret backdoor solution -- I would love to keep the Pro fields so it is more plug and play for the client once we hand it over to them (they can make and manage their own forms more easily). Commented Aug 21, 2013 at 14:24
  • 1
    As of this writing (Freeform 4.0.12), this is still the situation. Either write the select field manually, or use the {freeform:field:my_name} tag. Third workaround: you could maybe use javascript/jQuery to add an empty "-- Select --" value to your select fields. You can also file a feature request here, where users can rate the FR up: support.solspace.com/categories/53962/forums/213788
    – Solspace
    Commented Aug 21, 2013 at 17:26
0

I had this exact same issue and thought I had solved it with the following jQuery:

$(document).ready(function() {        
      $('#myList').append('<option value="1" selected="selected">-- None Selected --</option>;');   
 });

But, if the user left this option selected without choosing anything else from the select box, Freeform considered it invalid input and errored out. I wanted users not to have to select from this box, as "no selection" was a valid possibility.

I ended up adding "None Selected" as one of the entries in the channel, closing it so it wouldn't show in the channel but would still show in the select box on the form, and using the following jQuery to set it as the default choice.

$("#myList option[value=109]").attr("selected", "selected")

where 109 was the entry id of the "None Selected" entry I had created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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